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. They are described in the following list. FM/IMS also provides some functions that might be of use. They are also described in the following list. 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 one or more of the following:
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

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

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

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

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 character 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, if you want to select segments in which any character in field #22 is a blank, you can specify: POS(' ',#22) > 0

SUBSTR

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 character and is of length length, padded with pad if necessary. n is a positive whole number. If n is greater than the length of string, then 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, if you want to select segments in which characters 4-6 of field #22 are the string 'NOT', you can specify:
SUBSTR(#22,4,3) = 'NOT'