Useful functions

REXX provides a rich set of built-in functions, including character manipulation and conversion functions. Some of these functions might be of use when you are writing your comparison expressions. To call a function, type the function name directly followed by one or more arguments within parentheses. There can be no space between the function name and the left parenthesis. For example:
function(arguments)
A function call can contain up to 20 arguments separated by commas. Each argument can be:
Argument
Example
Blank
function( )
Constant
function(55)
Symbol
function(#5)
Literal string
function('With a literal string')
Option recognized by function
function(option)
Another function
function(function(arguments))
Combination of argument types
function('Literal string', #5, option)
Some of the built-in functions provided by REXX that you might find useful are:
ABS()
Figure 1.

1 ABS (number)
Returns the absolute value of a number. For example, to select records in which field #12 contains a value in the range -10 to +10, specify:
ABS(#12) <= 10
MAX()
Figure 2.

1 MAX (+ , number)
Returns the largest number from the list specified. For example, to select records in which any of fields #10, #11, or #12 contains a value greater than 55, specify:
MAX(#10, #11, #12) > 55
MIN()
Figure 3.

1 MIN (+ , number)
Returns the smallest number from the list specified. For example, to select records in which any of fields #10, #11, or #12 contains a value less than 0, specify:
MIN(#10, #11, #12) < 0
POS()
Figure 4.

1 POS ( needle , haystack
2.1 ,start
1)

Returns the position of one string, needle, in another, haystack. Returns 0 if needle is a null string, or is not found in haystack, or if start is greater than the length of haystack. By default, the search starts at the first byte of haystack (that is, the value of start is 1). You can override this by specifying start (which must be a positive whole number), the point at which the search starts. For example, to select records in which any character in field #22 is a blank, specify: POS(' ',#22) > 0

SUBSTR()
Figure 5.

1 SUBSTR (string,n
2.1 ,
2.2.1 length
2.2.1 ,pad
1)

Returns the substring of string that begins at the nth byte and is of length length bytes, padded with pad if necessary. n is a positive whole number. If n is greater than the length of string (in bytes), only pad characters are returned.

If you omit length, the rest of the string is returned. The default pad character is a blank.

For example, to select records in which bytes 4-6 of field #22 are the string 'NOT', specify:
SUBSTR(#22,4,3) = 'NOT'