Next: , Previous: , Up: Conditionals and Loops   [Contents][Index]

5.23.2 if-then

Request: .if cond-expr anything

Evaluate the conditional expression cond-expr, and if it evaluates true (or to a positive value), interpret the remainder of the line anything as if it were an input line. Recall from Invoking Requests that any quantity of spaces between arguments to requests serves only to separate them; leading spaces in anything are thus not seen. anything effectively cannot be omitted; if cond-expr is true and anything is empty, the newline at the end of the control line is interpreted as a blank input line (and therefore a blank text line).

.nr force-word-break 1
.if ((\n[force-word-break] = 1) & \n[.int])
    ⇒ supertanker super tanker
Request: .nop anything

Interpret anything as if it were an input line. This is similar to ‘.if 1’. nop is not really “no operation”; its argument is processed—unconditionally. It can be used to cause text lines to share indentation with surrounding control lines.

.als real-MAC MAC
.de wrapped-MAC
.  tm MAC: called with arguments \\$@
.  nop \\*[real-MAC]\\
.als MAC wrapped-MAC
\# Later...
.als MAC real-MAC

In the above, we’ve used aliasing, nop, and the interpolation of a macro as a string to interpose a wrapper around the macro ‘MAC’ (perhaps to debug it).