Allows conditional execution of jCL commands based on the evaluation of an expression, or the presence (or absence) of a reference.
IF{#} reference command
or
IF reference operator expression command
# tests for the absence of a value.
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround character. Using an A command will not move a value but simply provides a reference to the parameter to be tested.
operator performs a value comparison. Operators are:
= | Equal to |
# | Not equal to |
< | Less than |
> | Greater than |
[ | Less than or equal to |
] | Greater than or equal to |
expression follows the operator and can be one of the following:
command is any valid jCL command.
If the test result is true, the command at the end of the statement is executed. If the test yields false, command is ignored and processing continues with the next line.
Buffer pointers will not be moved if you use a direct or indirect reference to a buffer or select register.
Comparative tests are performed on a character-by-character, left-to- right basis. For example, AAB is greater than AAAB and 20 is greater than 100. Use the IFN command if you want to perform numeric comparisons. You can use also perform multiple conditional tests in a single statement. For example:
IF %1 > A IF %1 < D T %1 is B or C
021 IF %1 T "%1 is not null"
022 IF # %1 T "%1 is null"
023 ...
Line 21 tests for a value in the 1st parameter of the PIB and outputs a message if the parameter is not null. Line 22 tests for opposite case.
021 IF &1.1 = ABC GO 10
022 MV %3 &1.1
023 10 ...
If &1.1 contains ABC execution will branch to line 23. Otherwise, the value in &1.1 will be moved into %3.
010 T "Continue (Y/n) :",+
011 IP %1
012 S1
013 IF # A G 10
014 IF A(1,1) = Y G 10
015 IF A(1,1) = y G 10
016 XFinished
017 10 ...
If the user enters Y, y or <ENTER> to the prompt on line 11, execution will continue at label 10 on line 17. Otherwise, the program will terminate.
Compares an expression with one of several different expressions or values, and conditionally executes one of several commands.
IF reference = expression{]expression}... command{]command]}...
IF reference # expression{]expression}... command.
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround character. Using an A command will not move a value but simply provides a reference to the parameter to be tested.
expression follows the operator and can be one of the following:
] represents a value mark (Ctrl ])
command is any valid jCL command.
The multivalues feature of the IF command enables one IF statement to be used instead of a series.
Do not use O or X commands unless they are the last in the series. Commands after an O or X will be ignored.
The equal (=) operator, will perform a logical OR on the expressions. If the reference is equal to any expression, the condition is true. If more than one expression is true, the command corresponding to the first true expression is executed. If there are more expressions than commands, and the true expression does not have a corresponding command, the last command in the series will be executed. If there are more commands than expressions, remaining commands are ignored.
If you use the not equal (#) operator, a logical AND is performed on the expressions. The reference must not equal any expression in the series for the condition to be true. In this case, the first command specified is executed. Subsequent commands are ignored.
If a direct or indirect reference to a buffer or select register identifies a multivalued parameter, the same jCL statement is executed regardless of which of the multivalues is true. This means that each value will not access a different command - as it would have if you had specified it directly in the IF statement. For example:
MV %1 A]B]C]D
IF %1 = X]Y]Z]C GO 10]20]30]40
will cause program execution to continue from label 40.
To use the special multivalued forms of the GO and GOSUB commands, you must specify one label for each result of a multiple comparison. For example:
IF %2 = A]B]C]D GO 10]20]30]40
Note that this is a special case of the GO and GOSUB commands. If you need to mix command types in the resulting actions, you should not use this form of the GO and GOSUB commands. You can still achieve the same effect but each result must contain a separate command. For example:
IF %2 = A]B]C]" GO 10]GO 20]GO 30]XFinished
In this case, if the result of the test for null is true the program will terminate with a suitable message.
IF %1 = A]B]C G 10
If %1 is equal to A, B or C, control is transferred to label 10.
IF %2 # "AA"]&1.1](2N)]" GOSUB 1001
If %2 is not equal to AA, the content of &1.1, two numerics or null, control is transferred to subroutine 1001.
IF %3 = (#0N)]($ON) GO 10]MV #4 "DOLLARS"
If %3 equals a pound sign (#) followed by any (or no) numerics, control transfers to
the statement with label 10.
If %3 equals a dollar sign ($) followed by any (or no) numerics, the string
"DOLLARS" is moved into the output buffer.
Conditionally executes commands based on a comparison with a specified pattern.
IF reference operator (pattern) command
reference can be a direct or indirect reference to a buffer or select register, or an A command without a surround character. Using an A command will not move a value but simply provides a reference to the parameter to be tested.
operator performs a value comparison. Operators are:
= Equal to.
# Not equal to.
(pattern) is a format string enclosed in parentheses that tests for a specified numeric, alphanumeric or alphabetic string. A pattern format string can consist of any combination of the following:
(nA) | Tests for n alphabetic characters. If n is 0 (zero), any number of (or no) alphabetic characters are assumed to match. |
(nC) | Tests for n alphanumeric characters. If n is 0 (zero), any number of (or no) alphanumeric characters are assumed to match. |
(nN) | Tests for n numeric characters. If n is 0 (zero), any positive number of numeric characters are assumed to match. |
(nP) | Tests for n printable characters. If n is 0 (zero), any number of (or no) printable characters are assumed to match. |
(nX) | Tests for n characters. If n is 0 (zero), any number of (or no) characters are assumed to match. |
(string) | Tests for one or more specified characters. If string contains numeric characters, %, #, &, !, or spaces, it must be enclosed in quotes. |
For example, the pattern (2N"-"3A"-"2N) specifies a format of two numeric characters, a hyphen, three alphabetic characters, another hyphen and then two numeric characters.
command is a valid jCL command.
0X can only be used as the last specification in a pattern.
A null value will match any of the defined patterns such as (0A), (0N), or (0X).
If you want to test for spaces in the pattern, use double quotes, for example:
IF %n = (2A" "3N" "0X)
Ambiguous literal strings must be enclosed in quotes.
IF %3 = (3N1A) GO 10
If %3 matches three numerics followed by one alphabetic character, branch to label 10.
IF &1.2 # (2N"AAA") GOSUB 1001
If &1.2 does not equal two numerics followed by AAA, control will be transferred to subroutine 1001.
IF %1 # (2N*2A*0N) MV %1 "99*AA*1234"
If %1 does not equal two numerics, an asterisk, two alphabetics, an asterisk, and a number (or no numerics), move a string that does into %1.
IF &1.1 = ("(6X)") GO 100
If &1.1 contains "(ABC123)", control will be transferred to label 100.
IF &1.1 = ("("0X")") GO 100
If &1.1 contains "(ABC123)", control will not be transferred to label 100.
IF &1.1 = ("("0X) GO 100
If &1.1 contains "(ABC123)", control will be transferred to label 100.
JCL