.lm .ifnot hlp .hl 1 Conditional text .ifnot small Sometimes you might want similar but different versions of the same document. Here are three ways that might be accomplished: .list .le If the document is broken up into small sections, then master files that contain nothing but _.REQUIRE commands could be used to build the individual versions of the document from the constituent pieces by including only the appropriate sections. .le Define SUBSTITUTIONS that can take on different meanings for each version of the document. .le Use the _.IF, _.IF NOT, _.ELSE, _.ENDIF, _.VARIANT, and _.NO VARIANT statements to conditionalize sections of the document. These commands are discussed in this section. .end list 2 .note On multiple command lines, the _.IF, _.IF NOT, _.ELSE, and _.ENDIF commands must be first. .end note .endif small .endif hlp .HELPC IF .q _.IF aaa [bbb] ... .p.x IF causes the following text down to the next _.END aaa or _.ELSE aaa to be processed only if one or more of the labels aaa, bbb, ... have been defined by a _.VARIANT command. Otherwise the text is ignored. .ifnot small Each label can be up to $IFMAX$ numbers or letters in length in either upper or lower case. The label case is ignored, so ABC or abc are equivalent labels. .bb The only special symbols allowed in labels are the underscore "__" and the asterisk "_*". Other special symbols or blanks are not allowed. .eb If the labels have not been defined, text processing is suppressed until the next _.ENDIF or _.ELSE is encountered. .i5;(DSR supports only single labels) .if rsx.DHY.i5;ADDITIONAL HELP AVAILABLE: NOT ELSE END VARIANT IMMEDIATE Warning Aexample Bexample Cexample Dexample Eexample nesting restrictions .ehy .endif rsx .HELPD NOT .endif small .q _.IF NOT aaa [bbb] ... .p.x IF>NOT causes the following text down to the next _.END aaa or _.ELSE aaa to be ignored if one or more of the labels aaa, bbb, ... have been defined by a _.VARIANT command. Otherwise the text is processed. .q _.ELSE aaa .p.x ELSE changes true conditionals to false and false to true. .bb .ifnot small After an _.IF, the action is the same as if an _.IF NOT were issued with the same label. After an _.IF NOT the action is the same as if an _.IF were issued with the same label. Only a single _.ELSE should follow an _.IF or _.IF NOT. The label aaa must either be the same as the label for the previous _.IF or _.IF NOT, or it must be "_*". .eb .HELPD END .endif small .q _.ENDIF aaa .p.x ENDIF terminates the range of an _.IF or _.IF NOT statement. .ifnot small .bb The label aaa must either be the same as the label for the previous _.IF or _.IF NOT, or it must be _*. .eb The _.ENDIF command must not be used inside a defined command, or RUNOFF will not recognize it. If conditional text containing _.REQUIRE commands is not processed, any _.ENDIF inside one of the required files will not be seen. .note If a literal command is used inside an IF and the text is not processed, an _.ENDIF will still be recognized after the _.LITERAL because the literal command is not recognized, so the text following it will be treated as normal text. .end note .HELPD VARIANT .endif small .q _.VARIANT aaa [bbb] ... .qn _.NO VARIANT aaa [bbb] ... .x NO>VARIANT .p.x VARIANT defines a label aaa that is used to control the action of subsequent _.IF commands. If the label is present in the VARIANT statement, then _.IF aaa will cause text to be printed and _.IF NOT aaa will suppress text. _.NO VARIANT undefines the label aaa. The _.VARIANT command only affects subsequent IF/IFNOT commands, and has no affect on previous IF/IFNOT commands. .bb Multiple labels can be specified with one variant command. A label can contain a "_*" as the last character to indicate that the rest of the label is wild. If a label is wild, only the characters up to the "_*" are matched; the rest of the label is ignored. For example, "A_*" will define all labels beginning with A as variants. .eb .HELPD IMMEDIATE .bb .q _.IMMEDIATE IF label .qq _.IIF label .qn _.IMMEDIATE IFNOT label .qn _.IIFNOT label .p.x IMMEDIATE>IF .x IMMEDIATE>IF NOT are similar to _.IF and _.IFNOT except that they apply only to the rest of the current line and they are not followed by _.ELSE or _.ENDIF. This command can be used inside a defined command, and need not be the first command on a line. .HELPD WARNING .lm.note Warning If IF/ELSE/ENDIF commands are not the first command on a line, or if they are inside a defined command, they will be ignored and an error message will result. .en .eb .ifnot small .HELPD AEXAMPLE .s.tt 4.c;Example: .s.nf.LM+5 _.VARIANT NOTES1 _.IF NOTES1 This line is printed _.ELSE NOTES1 This line is not printed _.ENDIF NOTES1 _.IF NOT NOTES1 This line is not printed _.ENDIF NOTES1 _.IF undefined This line is not printed _.ENDIF undefined _.IFNOT undefined This line is printed _.ELSE undefined This line is not printed _.ENDIF undefined .f.lm-5 .HELPD BEXAMPLE .s.tt 4.c;Example: .s Consider the following problem: You have used a _.REQUIRE at the top of several _.RNO files to define some commonly used substitutions and escapes. You now make up a main _.RNO file that requires several of these _.RNO files. Unfortunately, the main file will cause the prefix file to be required several times, and each time it is required, a string of error messages will be generated: .i5;RNO -- Substitution already defined .br;The way to avoid this problem is to execute the prefix file only once. This can be guaranteed by putting the statement .i5;_.IFNOT prefix .br;at the top of the prefix file, and the statements .i5;_.VARIANT prefix .i5;_.ENDIF prefix .br;at the bottom of the prefix file. .HELPD CEXAMPLE .s.tt 4.c;Example: .p;Here is an example of the _.NO VARIANT command: .s.nf.LM+5 _.VARIANT abc _.IF abc This line will appear _.ENDIF abc _.NO VARIANT abc _.IF abc This line will not appear _.ELSE abc This line will appear _.ENDIF abc .f.lm-5 .test page 10 .HELPD DEXAMPLE .s.tt 4.c;Example: .p;Here is an example of multiple labels: .s.nf.LM+5 _.Variant abc _.IF abc def This line appears _.ENDIF _* _.IF abc This line appears _.ENDIF _* _.IF def This line will not appear _.ENDIF _* .f.lm-5 .HELPD EEXAMPLE .s.tt 4.c;IMMEDIATE example: .s The following illustrates the use of the IMMEDIATE IF command: .S .nf.LM+5 _.VARIANT A _.IIF A;This line appears. _.IIFNOT A;This line will not appear. _.IIF B;This line will appear. _.IIFNOT B;This line will not appear. .lm-5.f .HELPD NESTING .s.tt 4.c;Nesting .s IF statements can be nested one inside another. Remember, however, that once an _.IF#aaa or _.IFNOT#aaa causes text to be skipped, no further text will be processed until _.ENDIF#aaa. RUNOFF allows up to levels of nesting. Here is a nesting example: .S .nf.lm+5 _.VARIANT B _.IF B This line is processed _.IF C This line is not _.ELSE C _.IF B This line is processed _.ELSE B This line is not _.ENDIF B _.ENDIF C _.ELSE B This line is not _.IFNOT C This line is not _.ENDIF C _.ENDIF B .TEST PAGE 7 .S .i-5;Here is an example of improper nesting: .S _.IF B _.IF C _.ENDIF B _.ENDIF C .f .TEST PAGE 9 .HELPD RESTRICTIONS .s.c;RESTRICTIONS .p Each time you use IF/IFNOT/VARIANT commands, a label is added to the internal symbol table. If you have defined too many labels, RUNOFF will run out of dynamic memory. If multiple labels are used with an IF command, only the last one is added to the symbol table, so if you always use the same last label, you can safely have a large variety of labels before the last one. .endif small .lm