[NTG-context] How to define a command...

Peter Münster pmlists at free.fr
Thu Jan 5 21:17:10 CET 2012


On Thu, Jan 05 2012, Otared Kavian wrote:

> \define[3]\RandomCoeff{%
> 	\ctxlua{a = math.random(#2,#3)}
> %	\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected...

\setuprandomize[2012]
\define[3]\RandomCoeff{%
  \expandafter\def\csname Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}}
\starttext
\RandomCoeff{Alpha}{1}{10}
\RandomCoeff{Beta}{2}{20}
\CoeffAlpha
\CoeffBeta
\stoptext

-- 
           Peter


More information about the ntg-context mailing list