Block of code depending on a Lua value == Examples ===== Example 1: Date Macro ===<context mode="mkiv" source="yes">\startTEXpage[offset=5mm] %--- example (by WS, 3/2011):Commands Needed %\setvariable{NAME}{KEY}{VALUE} => \getvariable{NAME}{KEY} %\defineexpandable[n] %\doifnumberelse{TEXT}{TRUE_CASE}{FALSE_CASE}
\defineexpandable[1]\notToday{% \start\dorecurse{#1}{\increment\normalday}\currentdate\stop% }% \defineexpandable\Date{% \doifnumberelse{\getvariable{Document}{Date}}{\notToday{\getvariable{Document}{Date}}}{\currentdate}% }% \setvariable{Document}{Date}{today} Today is \Date. \setvariable{Document}{Date}{7} In a week will be \Date.\stopTEXpage</context> === Example 2: Using Lua ===We can also write tests using Lua. (Example by WS, 3/2011.) <texcodecontext mode="mkiv" source="yes">\starttextstartTEXpage
\ctxlua{test = true}
Test is \ctxlua{commands.testcasedoifelse(test)}{True}{False}.
\ctxlua{test = false}
Test is \ctxlua{commands.testcasedoifelse(test)}{True}{False}.\stoptextstopTEXpage</texcodecontext> == See also == [[System Macros/Branches and Decisions|Branches and Decisions]] == Help from ConTeXt-Mailinglist/Forum ==All issues with:{{Forum|{{SUBPAGENAME}}}}