Difference between revisions of "Command/doif..."

From Wiki
Jump to navigation Jump to search
m (Category:internals)
(Add list of doif... commands. Move Lua example to == Example ==)
Line 1: Line 1:
 
{{Reference|name=doif...|attributes=}}
 
{{Reference|name=doif...|attributes=}}
  
Block of code depending on a Lua value - example (by WS, 3/2011):
+
* <tt>\doifnextcharelse</tt>
 +
* <tt>\doifundefined</tt>, <tt>\doifdefined</tt>, etc.
 +
* <tt>\doif</tt>, <tt>\doifnot</tt>, <tt>\doifelse</tt>
 +
* <tt>\doifempty</tt>, <tt>\doifnotempty</tt>, <tt>\doifemptyelse</tt>
 +
* <tt>\doifinset</tt>, <tt>\doifnotinset</tt>, <tt>\doifnotinsetelse</tt>
 +
* <tt>\doifcommon</tt>, <tt>\doifnotcommon</tt>, <tt>\doifcommonelse</tt>
 +
* <tt>\doifsamestringselse</tt>,<tt>\doifsamestring</tt>,<tt>\doifnotsamestring</tt>
 +
* <tt>\doifinstringelse</tt>,<tt>\doifincsnameelse</tt>
 +
* <tt>\doifnumberelse</tt>
 +
* <tt>\doifassignmentelse</tt>
  
<context mode="mkiv" source="yes" text="Gives:">
+
<!--
 +
* {{cmd|doifnextcharelse}}
 +
* {{cmd|doifundefined}}, {{cmd|doifdefined}}, etc.
 +
* {{cmd|doif}}, {{cmd|doifnot}}, {{cmd|doifelse}}
 +
* {{cmd|doifempty}}, {{cmd|doifnotempty}}, {{cmd|doifemptyelse}}
 +
* {{cmd|doifinset}}, {{cmd|doifnotinset}}, {{cmd|doifnotinsetelse}}
 +
* {{cmd|doifcommon}}, {{cmd|doifnotcommon}}, {{cmd|doifcommonelse}}
 +
* {{cmd|doifsamestringselse}},{{cmd|doifsamestring}},{{cmd|doifnotsamestring}}
 +
* {{cmd|doifinstringelse}},{{cmd|doifincsnameelse}}
 +
* {{cmd|doifnumberelse}}
 +
* {{cmd|doifassignmentelse}}
 +
-->
 +
 
 +
== Example ==
 +
We can also write tests using Lua. (Example by WS, 3/2011.)
 +
 
 +
<context mode="mkiv" source="yes">
 
\starttext
 
\starttext
 
   \ctxlua{test = true}
 
   \ctxlua{test = true}

Revision as of 09:25, 22 May 2012

\doif...

  • \doifnextcharelse
  • \doifundefined, \doifdefined, etc.
  • \doif, \doifnot, \doifelse
  • \doifempty, \doifnotempty, \doifemptyelse
  • \doifinset, \doifnotinset, \doifnotinsetelse
  • \doifcommon, \doifnotcommon, \doifcommonelse
  • \doifsamestringselse,\doifsamestring,\doifnotsamestring
  • \doifinstringelse,\doifincsnameelse
  • \doifnumberelse
  • \doifassignmentelse


Example

We can also write tests using Lua. (Example by WS, 3/2011.)

\starttext
  \ctxlua{test = true}
 
   Test is \ctxlua{commands.testcase(test)}{True}{False}.
 
  \ctxlua{test = false}

  Test is \ctxlua{commands.testcase(test)}{True}{False}.
\stoptext

See also

Branches and Decisions

Help from ConTeXt-Mailinglist/Forum

All issues with: