Priority of operators – IBM SC34-5764-01 User Manual

Page 50

Advertising
background image

The result of this example is:

baseball

£ 5

A more sophisticated way to format information is with parsing and templates. Information about parsing
appears in section “Parsing Data” on page 73.

Priority of Operators

When more than one type of operator appears in an expression, what operation does the language
processor do first?

IF (A > 7**B) & (B < 3)

Like the priority of operators for the arithmetic operators, there is an overall priority that includes all
operators. The priority of operators is as follows with the highest first.

Table 2. Overall Operator Priority

\ or ¬ - +

Prefix operators

**

Power (exponential)

* / % //

Multiply and divide

+ -

Add and subtract

blank || abuttal

Concatenation operators

== = >< and so on

Comparison operators

&

Logical AND

| &&

Inclusive OR and exclusive OR

Thus, given the following values

A = 8
B = 2
C = 10

the language processor would evaluate the previous example

IF (A > 7**B) & (B < 3)

as follows:
1. Evaluate what is inside the first set of parentheses.

a. Evaluate A to 8.

b. Evaluate B to 2.

c. Evaluate 7**2.

d. Evaluate 8 > 49 is false (0).

2. Evaluate what is inside the next set of parentheses.

a. Evaluate B to 2.

b. Evaluate 2 < 3 is true (1).

/****************************** REXX *********************************/
/* This program formats data into columns for output.

*/

/*********************************************************************/

sport = 'base'
equipment = 'ball'
column = '

'

cost = 5

SAY sport||equipment column '£' cost

Figure 14. Example Using Concatenation Operators

Using Variables and Expressions

28

CICS TS for VSE/ESA: REXX Guide

Advertising