Chapter 5. Using Functions
What is a Function? .......................61
Example of a Function .....................62
Built-In Functions ........................63
Arithmetic Functions ......................63
Comparison Functions .....................63
Conversion Functions .....................64
Formatting Functions......................64
String Manipulating Functions ..................64
Miscellaneous Functions ....................65
Testing Input with Built-In Functions ................66
Exercise - Writing an Exec with Built-In Functions ..........66
This chapter defines what a function is and describes how to use the built-in
functions.
What is a Function?
Afunction is a sequence of instructions that can receive data, process that data, and
return a value. In REXX, there are several kinds of functions:
v Built-in functions — These functions are built into the language processor. More
about built-in functions appears later in this chapter.
v User-written functions — These functions are written by an individual user or
supplied by an installation and can be internal or external. An internal function is
part of the current exec that starts at a label. An external function is a
self-contained program or exec outside of the calling exec. More information
about user-written functions appears in “Writing a Function” on page 77.
v Function packages — These are groups of functions and subroutines written by
an individual user or supplied by an installation. They are link-edited into load
modules and categorized as user, local, and system. TSO/E external functions
are provided in a system function package. More information about TSO/E
external functions appears in “TSO/E External Functions” on page 119.
Regardless of the kind of function, all functions return a value to the exec that
issued the function call. 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.
function(arguments)
A function call can contain up to 20 arguments separated by commas. Each
argument can be one or more of the following.
v Blank
function( )
v Constant
function(55)
v Symbol
function(symbol_name)
v Literal string
function('With a literal string')
v Option recognized by the function
© Copyright IBM Corp. 1988, 2001 61