Specifying values when calling a program
REXX add 42 21
/**************************** REXX ******************************/
/* This
program
receives two numbers as input, adds them, and */
/* produces their sum. */
/****************************************************************/
ARG number1 number2
sum = number1 + number2
SAY 'The sum of the two numbers is' sum'.'
ARG assigns the first number 42 , to number1 , and the second number 21 , to number2.
If the number of values is fewer or more than the number of variable names after ARG or PULL, errors can occur, as the following sections describe.
Specifying too few values
REXX add 42
The language processor assigns the value 42 to number1 , the first variable following ARG. It assigns the null string to number2 , the second variable. In this situation, the program ends with an error when it tries to add the two variables. In other situations, the program might not end in error.
Specifying too many values
REXX add 42 21 10
The language processor assigns the value 42 to number1 , the first variable following ARG. It assigns the value 21 10 to number2 , the second variable. In this situation, the program ends with an error when it tries to add the two variables. In other situations, the program might not end in error.
ARG number1 number2 .
ARG . number1 number2
In this case, the first value, 42, is discarded and number1 and number2 get the next two values, 21 and 10.