*IF Test Condition

*IF &[&]var1 op  [ [C|L|X] 'string' | &[&]var2 ] cmd

The contents of the variable &var1 is compared with the value of the character string enclosed in quotes, or with the contents of the procedure variable &var2.

&var1 | &var2

&name [ ( [s] [, l] ) ]

Name of a procedure variable or a substring of a variable.

s optional specification of the start column for the substring of the procedure variable. ( 1 <= s < 80 ).

Standard: s = 1.

l specification of the length of the procedure variable substring. ( 1 <= l <= 80 ).

The special characters * or $ can be used in the first comparison operand (&var1) for l. The exact usage of these characters is described in detail in a later section.

Standard: l = Total length of the variable.

Examples:

&FILE(4) Contents of the variable &FILE, from column 4 to the end of the variable

&FILE(4,20) Contents of the variable &FILE, from column 4 for a length of 20

&FILE(,20) Contents of the variable &FILE, from column 1 for a length of 20

&&var1 | &&var2

The contents of the variables &var1 | &var2 will be regarded as the name of another variable whose contents should then be evaluated.

Example: &NA='CON1'. Specifying &&NA will evaluate the contents of the CFS-internal variable &CON1. Another example of double substitution can be found on page 20-.

op Comparison operator: [-] { > | < | = }

If the alphanumeric comparison of greater than (>) / less than (<) / equal to (=) is true / false (-), then the command specified as cmd will be executed.

[C|L|X]'string' constant character string. Any single quotation marks appearing in the string must be entered twice ('').

The contents of the variable to the left of the equality sign or the partial string will be compared with the specified constant. Equality will only be flagged if the respective lengths match as well as the contents. Null characters not contained in the constant will result in the values not being declared equal. For further information, see the following section.

If string contains pure numerical values, the quotes can be omitted.

Examples: *IF &N=1, *&COUNTER>-10

cmd any CFS procedure language statement. The standard asterisk that prefixes a statement must not be included.

The characters * or $ have special meanings when comparing to constants

* Only compare the length of the variable to the left of the equality sign with that of the constant on the right. Additional characters in the variable will be ignored. &VAR(,*) can be abbreviated to &VAR(*).

$ Expand the constant to the right of the equality sign until the string returns the same length as the variable with which it must be compared.

&VAR(,$) can be abbreviated to &VAR($).

Examples:

*IF &FILE(,*)='ABC' SKIP .ABC or in abbreviated format:

*IF &FILE(*)='ABC' SKIP .ABC

The first three characters of the variable &FILE will be compared with the constant 'ABC', and if equal, a jump to label .ABC will be executed.

*IF &FILE(25,*)=' ' SKIP .A25

The contents of the variable &FILE will be compared from column 25 for a length of 1 byte with the constant '_' . If they are equal, a junp to label .A25 will be executed.

*IF &FILE(,$)=' ' SKIP .A27 or in abbreviated form:

*IF &FILE($)=' ' SKIP .A27

The total contents of the variable &FILE will be compared with an equal number of null characters. If &FILE consists only of null characters, a jump to label .A27 will be executed.

*IF &FILE(25,$)=' ' SKIP .A25

A check will be made to determine whether the variable &FILE contains null characters (at least one) from column 25 on. If so, a jump to label .A25 will be executed.

Note:

When comparing a procedure variable with a constant or with a second procedure variable, case is not normally taken into account. The statement *SET CASE=Y can be issued to force a case check.

Examples:

*IF &FIL='' PROMPT &FIL,'Please enter filename '

If the &FIL variable is empty, the user will be requested to enter a value via the *PROMPT statement.

*IF &FIL=&D2 SKIP .SAME

If the value of the &DAT variable is equal to that of the &D2 variable, then a branch will be made to the label ".SAME".

*IF &COUNTER>9 EXIT

The procedure will be terminated if the &COUNTER variable has a value greater than 9

Further examples for the assignment of variables can be found on page 20-.