Conditioning Expressions

The WHILE, UNTIL, CASE, IF and ELSEIF directives require that you specify a conditioning expression.  In addition, conditioning expressions may optionally be specified with LEAVE, CONTINUE, SUSPEND and TERMINATE directives.

The simplest form of conditioning expression consists of left and right operands separated by a comparison operator such as *EQ (equal).  This is an example of a simple conditioning expression:

&MYNUMBER *GT 3

 

For more information on this form of conditioning expression refer to:

Simple Conditioning Expressions

Simple Conditioning Expression Examples

 

For more complex cases, you may specify a compound conditioning expressions.  This type of expression consists of two or more simple expressions with conjunctions and optional parentheses.  This is an example of a compound conditioning expression:

(&MYNUMBER *GT 3) *AND (&MYSTRING *EQ 'ABC')

 

For more information on this form of conditioning expression refer to:

Compound Conditioning Expressions

Compound Conditioning Expression Examples

 

Simple Conditioning Expressions

A simple conditioning expression consists of the following parts:

Left Operand

The name of a variable or Built-in variable whose value is tested by the expression.

To specify a variable, precede the variable name with an ampersand (&) – for example &VARIABLE1. To specify an indexed variable, specify a variable or numeric literal that specifies the index value in parentheses immediately following the variable name – for example &VARIABLE1(&INDEX1).

To specify a built-in variable, enter the name, including the asterisk, as shown on the Built-ins tab – do not precede a built-in variable name with ampersand.

Operator

A comparison operator used to compare the value of the left and right operands. It may be one of the following:

*EQ  =  Equal

*NE  <>  Not equal

*GT  >  Greater than

*GE  >=  Greater than or equal

*LT  <  Less than

*LE  <=  Less than or equal

Right Operand   

The value that is compared to the variable specified by the left operand. The value can be specified in one of two ways:

1.   A numeric or alphanumeric literal value. If you enter an alphanumeric literal value you must surround it with quote marks. The quote marks do not become part of the value used for the comparison. If you need to embed quote marks in the value, you should double-up the embedded quote marks.

2.   The name of a variable or built-in variable that supplies the value used for the comparison. To specify a variable, precede the variable name with an ampersand (&) – for example &VARIABLE1. To specify a built-in variable, enter the name, including the asterisk, as shown on the Built-ins tab – do not precede a built-in variable name with ampersand. To specify an indexed variable, specify a variable or numeric literal that specifies the index value in parentheses immediately following the variable name – for example &VARIABLE1(&INDEX1).

 

Simple Conditioning Expression Examples

This expression is true when the value of the variable named MYNUMBER is greater than 3:

&MYNUMBER *GT 3

This expression is true when the value of the variable named MYSTRING: is ABC:

&MYSTRING *EQ 'ABC'

This expression is true when the value of the second instance of the MYLIST variable list is B:

&MYLIST(2) = 'B'

This expression is true when the value of the MYLETTER variable is not equal to the value of the third instance of the MYLIST variable list:

&MYLETTER <> &MYLIST(3)

This expression is similar but the MYINDEX variable specifies which instance of the MYLIST variable list to use for the comparison:

&MYLETTER <> &MYLIST(&MYINDEX)

This expression is true when the value of the *TRADINGPARTNER built-in variable is ATLAS:

*TRADINGPARTNER = 'ATLAS'

 

Compound Conditioning Expressions

A compound conditioning expression consists of two or more simple expressions, combined with:

Conjunctions

You must specify a conjunction between two sub-expressions that identifies the relation between the expressions that must be satisfied.  The conjunction may be one of the following:

*AND  ("and" – both the sub-expressions to the left and right of the *AND must be satisfied)

*OR  ("or" – either the sub-expression to the left or to the right must be satisfied)

Parentheses

You may optionally specify opening and closing parentheses around sub-expressions to nest them and thereby explicitly control the extent of the sub-expression that is affected by a given conjunction.

 

There is no inherent limit to the number of sub-expressions forming a compound conditioning expression, nor to the depth of nesting, although there is an overall maximum expression length of 1000.  In any event, for reasons both of maintainability and performance, we recommend that you avoid excessively complex conditioning expressions.

 

Compound Conditioning Expression Examples

This expression is true when BOTH of the simple expressions are true:

&MYNUMBER *GT 3 *AND &MYSTRING *EQ 'ABC'

This expression is true when EITHER one (or both) of the simple expressions are true.  Note that the parentheses in this example are not strictly necessary, but they can help to make the intent clear to an observer:

(&MYNUMBER *GT 3) *OR (&MYSTRING *EQ 'ABC')

This expression is true when EITHER one (or both) of the simple expressions contained within the parentheses is true, AND the value of variable &MYDAY is 'MONDAY':

(&MYNUMBER *GT 3 *OR &MYSTRING *EQ 'ABC') *AND &MYDAY = 'MONDAY'