I'm trying to create a set of macro-s for plain [Xe]TeX to be able to create Nassi-Shneidermann Diagrams that produces a table (\halign
). (I would note the cases slant lines differently in a way, that we can ignore it for this question.)
To create a table, I need to know the columns number of the final NSD, so I need to accumulate the commands. But if I accumulate the commands, I also have to put information that at the time I call a macro, I cannot know it, namely the number of columns.
So the question is, how can I make some sort of container, that can accumulate tokens, and when expanded with a parameter, it would put in the proper final result? For an example, if we ignore the borders of such diagram and I would like to put a command structure before an if-then-else structure in the diagram, it would produce a \span\omit
pair in the command's cell, or with a 5 case structure, it would put 4 \span\omit
macro pairs.
I don't know how I want it to be like in it's final stage but for an exact specific example, I want something like this:
\beginstruct
\command{i:=1}
\strutif i≠5
\then
j:=j-1
\else
SKIP
\strutfi
\endstruct
to yield something like this:
\halign{
&#\vrule&\hfil#\hfil\cr
\noalign{\hrule}
&i:=1\multispan2&\cr
\noalign{\hrule}
&\char`\\\hfill i≠5\hfill/\multispan2&\cr
\noalign{\hrule}
&j:=j-1&&SKIP&\cr
\noalign{\hrule}
}
But if I only write:
\beginstruct
\command{i:=1}
\endstruct
would yield something like:
\halign{
&#\vrule&\hfil#\hfil\cr
\noalign{\hrule}
&i:=1&\cr
\noalign{\hrule}
}
The problem here is that I need to know how that there is 2 collumns (excluding the borders) are there before I could write any number to \multispan
. In my first example, the \multispan
after i:=1
have 2 as parameter, but it is not presents after the second example.
\omit\span
sounds a lot like\multispan
– morbusg Oct 5 '11 at 17:53\halign{&\vrule#&\hfil#\hfil\cr...}
ie. repeat? – morbusg Oct 5 '11 at 18:01\multispan
is a better solution, and generally the position of te#
sign around\vrule
is not interesting to me. – Adam L. S. Oct 5 '11 at 20:41