Relational Operators ARexx offers the following relational operators: > greater than >= or ~< greater than or equal to < less than <= or ~> less than or equal to = equality ~= inequality == exact equality ~== exact inequality The need for alternative forms of equality and inequality operators stems from the fact that ARexx variables which hold numbers are stored, like all other ARexx variables, as text strings. If you consider these variable assignments: m='09', n='9', p=' 9' and q='9.0', it's pretty obvious that, despite the fact that as text strings all four examples are different, you would expect ARexx, for numerical purposes, to behave as though the variables represented the same numbers. To accomodate these conflicting views, ARexx allows a number of different comparison modes. Exact comparisons work on a strict character-by-character basis and include all characters of the string (including leading and trailing blanks). Ordinary string comparisons work much the same way as you might do when comparing words - ARexx ignores leading blanks and, if necessary, pads the shortest string with blanks before making the comparison. With number comparisons ARexx first converts the operands to its internal number form and then uses standard arithmetic operations to perform the comparison. Logical Operators ARexx provides four logical operations: AND, OR, NOT and Exclusive-OR, with these symbols being used: & AND | OR ~ NOT ^ or && Exclusive OR All require true/false (Boolean) type operands and produce a result which is either true or false. ARexx considers 0 to be false and 1 to be true and, unlike some languages, it expects true/false expressions to equate to either zero or unity. Operator Precedence The ARexx language, like all high-level languages, has a set of rules, called precedence rules, which determine the order in which expression operands are used. With ARexx the expression, x = 7 * 2 + 1, for instance, results in x being set to 15, because the multiplication is done first (had the addition been done first the result would have been 21). The multiplication operator (*) is said to have a higher precedence than the addition operator (+). To force ARexx to evaluate the addition part first you can place parenthesis around the 2+1 part of the expression: x = 7 * ( 2 + 1 ). Unless re-ordered by parenthesis, ARexx operators of highest priority will always be evaluated first, followed by those of next highest priority and so on. Table 1 gives the details of the various ARexx operators. Symbol Precedence level Name ~ 8 Logical NOT + 8 Unary plus - 8 Unary minus ** 7 Exponentiation * 6 Multiplication / 6 Division % 6 Integer division // 6 Modulo (remainder) + 5 Addition - 5 Subtraction || 4 String concatenation (blank) 4 Blank concatenation > 3 Greater than >= or ~< 3 Greater than or equal to < 3 Less than <= or ~> 3 Less than or equal to = 3 Equality ~= 3 Inequality == 3 Exact equality ~== 3 Exact inequality & 2 Logical AND | 1 Logical inclusive OR ^ or && 1 Logical Exclusive OR Table 1: Details of the ARexx operator precedence. ARexx expressions are, give or take a few symbol changes, much the same as Basic language expressions. If for example you wanted to test some number variable to see if it was odd or even, you mightc write in BASIC: if (x mod 2) then gosub OddMessage else gosub EvenMessage With ARexx, as we saw in the first part of this series, you'd write: if x//2 then call OddMessage() else call EvenMessage(). Hopefully, this will make the use of Arexx easier for you. Details of our next Arexx articles can be found at the end of the Arexx article in this month's magazine, but for First Steps, that's all folks!