Changes

Jump to navigation Jump to search
m
Get rid of <cmd>...</cmd> syntax
< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops_and_Recursion|Loops and Recursion]] >
===<cmd>\doifnextcharelse</cmd>===
When Pragma ADE started using TeX in the late eighties, their first experiences with programming concerned a simple shell around LaTeX. The commands probably used most at Pragma ADE are the itemizing ones. One of those initial shell commands took care of an optional argument, that enabled the specification of the item symbol to be used. Without understanding anything they were able to locate a LaTeX macro that could be used to inspect the next character.
</texcode>
===<cmd>\doifundefined</cmd>, <cmd>\doifdefined</cmd>, etc.===
The standard way of testing if a macro is defined is comparing its meaning with another undefined one, aptly named <code>\undefined</code>. To guarantee correct working of this set of macros, <code>\undefined</code> may '''never''' be defined by a user!
</texcode>
===<cmd>\doif</cmd>, <cmd>\doifnot</cmd>, <cmd>\doifelse</cmd>===
Programming in TeX differs from programming in procedural languages like Modula. This means that one --- well, let me speek for myself --- tries to do the things in the well known way. Therefore the next set of <code>\ifthenelse</code> commands were between the first ones we needed. A few years later, the opposite became true: when programming in Modula, I sometimes miss handy things like grouping, runtime redefinition, expansion etc. While Modula taught me to structure, TeX taught me to think recursive.
These macros test string equality of the (expanded) first two arguments.
===<cmd>\doifempty</cmd>, <cmd>\doifnotempty</cmd>, <cmd>\doifemptyelse</cmd> ===
We complete our set of conditionals with:
This time, the string is not expanded. Remember to expand it yourself where needed.
===<cmd>\doifinset</cmd>, <cmd>\doifnotinset</cmd>, <cmd>\doifnotinsetelse</cmd>===
We can check if a string is present in a comma separated set of strings. Depending on the result, some action is taken.
The second argument is the comma separated set of strings. If the first string expands 'empty', it is considered to be '''not''' in the set. The comma separated set is not expanded.
===<cmd>\doifcommon</cmd>, <cmd>\doifnotcommon</cmd>, <cmd>\doifcommonelse</cmd> ===
Probably the most time consuming tests are those that test for overlap in sets of strings.
</texcode>
===<cmd>\doifsamestringselse</cmd>,<cmd>\doifsamestring</cmd>,<cmd>\doifnotsamestring</cmd>===
The next comparison macro converts the arguments into
instance <code>\jobname</code> with a name stored in a macro.
===<cmd>\doifinstringelse</cmd>,<cmd>\doifincsnameelse</cmd>===
We can check for the presence of a substring in a given sequence of characters.
Where <code>\doifinstringelse</code> does as much expansion as possible, the latter alternative does minimal (one level) expansion.
===<cmd>\doifnumberelse</cmd>===
The next macro executes a command depending of the outcome of a test on numerals.It checks only the first character of string.
</texcode>
===<cmd>\doifassignmentelse</cmd>===
A lot of ConTeXt commands take optional arguments, for

Navigation menu