[NTG-context] Building tables at runtime via --mode= option
Bart C. Wise
bntgcontext at wiseguysweb.com
Tue Dec 9 15:08:09 CET 2008
I'm trying to build a table in a project that will be built based on a
commandline parameter. Currently, I'd like to use the "--mode=<>" command.
However, I've run into a number of snags that I have attempted to solve
without any luck. I've included some sample code of what I would like to do.
I can do all of what I need using \doifmodeelse, etc. However, I'm looking
for a more elegeant solution. Any hints/solutions are welcomed!
Problems:
1) \currentmode: I cannot use this variable in my file, but it works in the
source code. Question: Is the mode option okay, or is there a better way?
2) CellWidth (below) needs to be a floating point dimension, based the size of
the paper. So I need to divide the size of the paper (\textwidth) by a number
and make sure it stays as a dimension.
3) I tried to use \getnumber[Rounds] to span a number of columns (
\bTD[nc=\getnumber[Rounds]]) but this would not compile. Here's the error:
Runaway argument?
Rounds=\plusone \ifnum \tblny =\plusone \ifnum \currentcol >\maximumcol \ETC.
! Paragraph ended before \getnumber was complete.
Sample:
\definenumber[Rounds]
\setnumber[Rounds]{6}
% desire: \setupnumber[Rounds]{\currentmode}
% and verify that it's a number between a given range.
% \currentmode comes back as undefined
\definenumber[TotalCol]
\setnumber[TotalCol]{\getnumber[Rounds] + 2}
\def\CellWidth{0.625in}
% desire: based on textwidth: \textwidth / \getnumber[TotalCol]
% Needs to be floating point
\starttext
Rounds: \getnumber[Rounds]\crlf
TotalCol: \getnumber[TotalCol]\crlf
CellWidth: \CellWidth\crlf
\bTABLE[align={middle,lohi},strut=no,width=\CellWidth]
% Row 1
\bTR[frame=off]
\bTD\eTD
\bTD[nc=6] Title\eTD
%desire: \bTD[nc=\getnumber[Rounds]] Title\eTD
\eTR
%Row 2
\bTR
\bTD\eTD
\dorecurse{\getnumber[Rounds]}{\expanded{\bTD\recurselevel\eTD}}
\bTD\eTD
\eTR
%Row 3
\bTR
\dorecurse{\getnumber[TotalCol]}{\expanded{\bTD\recurselevel\eTD}}
\eTR
\eTABLE
\stoptext
Thanks!
Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20081209/31ad9ed8/attachment.html>
More information about the ntg-context
mailing list