Am 12.07.2011 um 17:30 schrieb Jaroslav Hajtmar:

> Hello ConTeXist.
> 
> How best (optimally) in Lua code in ConTeXt define own ConTeXt macros?
> 
> I was used recently LuaTeX syntax (for example) :
> tex.sprint(tex.ctxcatcodes,'\\def\\mymacro\{arg of mymacro\}')
> 
> But someone advised me that I use the better syntax:
> context('\\def\\Mymacro\{arg of mymacro\}')
> or context("\\def\\test#1{#1}") etc...
> 
> Exist other (best or most optimal) way to do?


You can use “context.setvalue”. To convert numbers in different formats
you can use the \convertnumber command.

\starttext

\startluacode
context.setvalue("One","1")
context.setvalue("Two","2")
\stopluacode

\define\Three{3}

\One:\Two:\Three

\blank

\startluacode
context.define({2},"\\CMDA","[One:#1,Two:#2]")
\stopluacode

\define[2]\CMDB{[One:#1,Two:#2]}

\CMDA{1}{2}
\CMDB{1}{2}

\blank

\convertnumber{R}{1400}

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to