After completing this chapter, you will be able to define Parsing capabilities.
The Terminal instruction 'PULL' is used to receive input from the terminal. PULL opens an input field on the terminal and waits for you to press Enter. This instruction takes information from the data stack, and when the data stack is empty.
For example (PARSE UPPER PULL causes the same result as PULL in that it will changes character information to uppercase before assigning it to one or more variables
ARG Instruction: Takes information passed as arguments to an exec, function, or subroutine, and puts it into one or more variable names.
For example (PARSE UPPER ARG causes the same result as ARG in that it will changes character information to uppercase before assigning it to one or more variables).
PARSE VALUE…. WITH INSTRUCTION: Parses a specified expression, such as a literal string, into one or more variable names that follow the WITH sub keyword.
PARSE VALUE 'Knowledge is Power' WITH word1 word2 word3 |
For the above statement the word1 contains 'Knowledge', word2 contains 'is' and word3 contains 'Power'.
The Terminal instruction 'SAY' is used to display output or displays the line on the terminal.
Say 'Enter your Age' Pull Age /* What ever you type as your age is converted into upper case and stored in age */ Parse Pull Age /* same as above, but input is not converted to upper case */ Say 'Enter your First and Last name' Pull fname lname /* REXX assumes variables are delimited by spaces */ |
The values which are passed to an exec are usually called arguments. Arguments can consist of one word or a string of words separated by blanks. Each argument should be separated by a comma.
ARG number1, number2 Sum = number1 + number2 Say 'Sum of two numbers is ' Sum |
PULL & SAY are the basic I-O statements in REXX.
PARSE command is used for string manipulation.
Special keywords such as SIGNAL, VAR, RC cannot be used as variable name.
Data types of variables need not be declared in REXX.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!