IBM SC34-5764-01 Server User Manual


 
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.
To prevent the last variable from getting the remaining values, use a period (.) at the end of the PULL or
ARG instruction.
ARG number1 number2 .
The period acts as a dummy variable to collect unwanted extra information. (In this case, number1 receives
42, number2 receives 21, and the period ensures the 10 is discarded. If there is no extra information, the
period is ignored. You can also use a period as a placeholder within the PULL or ARG instruction as
follows:
ARG . number1 number2
In this case, the first value, 42, is discarded and number1 and number2 get the next two values, 21 and 10.
Preventing Translation of Input to Uppercase
Like the PULL instruction, the ARG instruction changes alphabetic characters to uppercase. To prevent
translation to uppercase, use PARSE ARG as in the following example.
Exercises - Using the ARG Instruction
The left column shows the input values sent to a program. The right column is the ARG instruction within
the program that receives the input. What value does each variable receive?
Input Variables Receiving Input
1. 115 -23 66 5.8
ARG first second third
2. .2 0 569 2E6
ARG first second third fourth
3. 13 13 13 13
ARG first second third fourth fifth
4. Weber Joe 91
ARG lastname firstname score
5. Baker Amanda Marie 95
PARSE ARG lastname firstname score
6. Callahan Eunice 88 62
PARSE ARG lastname firstname score .
ANSWERS
1. first = 115, second = -23, third = 66 5.8
2. first = .2, second = 0, third = 569, fourth = 2E6
3. first = 13, second = 13, third = 13, fourth = 13, fifth = null
/**************************** REXX ********************************/
/* This program receives the last name, first name, and score of */
/* a student and reports the name and score. */
/******************************************************************/
PARSE ARG lastname firstname score
SAY firstname lastname 'received a score of' score'.'
Figure 10. Example of a program That Uses PARSE ARG
Writing and Running a REXX Program
16
CICS TS for VSE/ESA: REXX Guide