Changes

Jump to navigation Jump to search
363 bytes added ,  23:52, 8 September 2023
Added another example
* <tt>\doifnumberelse</tt>
* <tt>\doifassignmentelse</tt>
* <tt>\doiftext</tt>, <tt>\doiftextelse</tt> — empty string
* <tt>\doifrightpageelse</tt> (precede by {{cmd|signalrightpage}})
* {{cmd|doifdocumentargument}}
* <tt>{{cmd|doifelseindented}}</tt> (LMTX only)
== Examples ===== Example 1: Date Macro ===<!context mode="mkiv" source="yes">\startTEXpage[offset=5mm] %--- Commands Needed* %\setvariable{NAME}{cmd|doifnextcharelseKEY}{VALUE}* {=> \getvariable{cmd|doifundefined}NAME}, {{cmd|doifdefinedKEY}}, etc.* { %\defineexpandable[n] %\doifnumberelse{cmd|doif}TEXT}, {{cmd|doifnot}TRUE_CASE}, {{cmd|doifelse}FALSE_CASE}* \defineexpandable[1]\notToday{% \start\dorecurse{cmd|doifempty#1}}, {{cmd|doifnotempty\increment\normalday}\currentdate\stop% }, % \defineexpandable\Date{{cmd|doifemptyelse}}%* \doifnumberelse{\getvariable{cmd|doifinsetDocument}}, {{cmd|doifnotinsetDate}}, {\notToday{\getvariable{cmd|doifnotinsetelse}Document}* {{cmd|doifcommonDate}}, {{cmd|doifnotcommon}}, {{cmd|doifcommonelse\currentdate}% }% * { \setvariable{cmd|doifsamestringselse}Document},{{cmd|doifsamestringDate}},{{cmd|doifnotsamestring}today}* Today is \Date. \setvariable{Document}{cmd|doifinstringelseDate}},{{cmd|doifincsnameelse}7}* {{cmd|doifnumberelse}} In a week will be \Date.* {{cmd|doifassignmentelse}}\stopTEXpage--</context>
=== Example 2: Using Lua ===
We can also write tests using Lua. (Example by WS, 3/2011.)
<context 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
</context>
194

edits

Navigation menu