Specify Conditions in Editor Macros

Conditions in macros are based on true or false comparisons. Depending on the type of macro instruction specifying a condition, if a specified condition is true, an action is either taken or continues. If a specified condition is false, an action is either not taken or stops. In some cases, you can also specify an action to take if a condition is false.

The simplest comparison compares two terms against each other. For example:

  a = b  - true if the value of a is equal to the value of b 
  a < b  - true is the value of a is less than the value of b 
  a > b  - true is the value of a is greater than the value of b 

Terms in a comparison can include numeric or string constants, numeric or string variables, or REXX functions that return numeric or string values. Comparisons must, however, be of terms of like type. String values cannot be compared with numeric values.

Conditions can also be based on a combination of comparisons. Each comparison is enclosed within parenthesis, and the logical operators OR (|) and AND (&) are used to combine comparisons.

Use the OR logical operator for conditions that should be taken if any one or more of the specified comparisons is true. For example:

  (a = b) | (c = d)            - true if either or both of the following are true:
                                     - the value of a is equal to the value of b 
                                     - the value of c is equal to the value of d 
  (a = b) | (e < f) | (g > h)  - true if any one or more of the following are true:
                                     - the value of a is equal to the value of b 
                                     - the value of e is less than the value of f 
                                     - the value of g is greater than the value of h 

Use the AND logical operator for conditions that should be taken if all of the specified comparisons is true. For example:

  (a = b) & (c = d)            - true if both of the following are true:
                                     - the value of a is equal to the value of b 
                                     - the value of c is equal to the value of d 
  (a = b) & (e < f) & (g > h)  - true if all of the following are true:
                                     - the value of a is equal to the value of b 
                                     - the value of e is less than the value of f 
                                     - the value of g is greater than the value of h 

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