About this task
Calculations that functions represent often require many instructions.
For instance, the simple calculation for finding the highest number
in a group of three numbers, might be written as follows:
Figure 1. Finding
a Maximum Number/***************************** REXX **********************************/
/* This program receives three numbers as arguments and analyzes */
/* which number is the greatest. */
/*********************************************************************/
PARSE ARG number1, number2, number3 .
IF number1 > number2 THEN
IF number1 > number3 THEN
greatest = number1
ELSE
greatest = number3
ELSE
IF number2 > number3 THEN
greatest = number2
ELSE
greatest = number3
RETURN greatest
Rather than writing multiple instructions every time you want to
find the maximum of a group of three numbers, you can use a built-in
function that does the calculation for you and returns the maximum
number. The function is called MAX, and you can use it as follows:
MAX(number1,number2,number3,....)
To find the maximum of 45, -2,
number, and 199 and put
the maximum into the symbol
biggest, write the following
instruction:
biggest = MAX(45,-2,number,199)