Perform the IF Statement in Editor Macros

You can use the REXX IF statement to control instruction flow within your macro. You can specify an action or actions to take if a specified condition is true, and you can also specify actions to take if that condition is not true.

The basic forms of the IF statement are shown below:

IF condition_true THEN 
    action 
 
IF condition_true THEN
    action1  
ELSE         
    action2  

In the most basic form, an action is performed only when the IF condition is satisfied. The ELSE clause lets you also specify an action to take when the condition is not satisfied.

If you want to perform several actions as a result of an IF decision, you need to enclose those actions within a DO-END structure, as shown below.

IF condition_true THEN 
    DO
        action1
        action2
        action3
    END
 
IF condition_true THEN
    DO
        action1
        action2
        action3
    END
ELSE         
    DO
        action4
        action5
        action6
    END

The condition can be specified using any combination of REXX variable and constant terms, REXX functions, and logical and comparison operators.


Specify Conditions in Editor Macros
Perform Constants and Variables in Editor Macros
Perform REXX Functions in Editor Macros