Changes

Jump to navigation Jump to search
no edit summary
< '''Prev:''' [[System Macros/Branches and DecisionsLoops_and_Recursion|Branches Loops & DecisionsRecursion]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Comma Separated Lists|Comma Separated Lists]] > [[Category:System Macros]][[Category:ConTeXt programming]]
ConTeXt makes extensive use of a sort of case or switch command. Depending of the presence of one or more provided items, some actions is taken. These macros can be nested without problems.
</texcode>
== Problems with expansion ==Be aware that <code>\processaction</code> is not fully expandable. This means that the following won't work. <texcode>\def\MyMacro#1{\processaction[#1][a=>\a,b=>\b]}\edef\x{\MyMacro{a}}</texcode> A solution in MkIV proposed by Taco on [[http://archive.contextgarden.net/message/20100513.073030.d6d1fa3a.en.html 2010-05-13]] is to define <code>\MyMacro</code> as follows <texcode>\def\MyMacro#1{\directlua{ local known = {a = '\a', b = '\b'} tex.sprint(known['#1'] or '\a')}}</texcode> Another way that should work in MkII too: <texcode>\getparameters[MyMacro:][a=\a,b=\b]\def\MyMacro#1{\doifdefinedelse{MyMacro:#1}{\getvalue{MyMacro:#1}}{\a}}</texcode>  < '''Prev:''' [[System Macros/Branches Loops and DecisionsRecursion|Branches Loops & DecisionsRecusion]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Comma Separated Lists|Comma Separated Lists]] >
[[Category:System MacrosProgramming and Databases]][[Category:ConTeXt programmingTools]]

Navigation menu