PARSE VAR Instruction
The PARSE VAR instruction parses a specified variable into one or more variable
names that follow it. If the variable contains character information, it is not changed
to uppercase.
quote = 'Knowledge is power.'
PARSE VAR quote word1 word2 word3
The PARSE UPPER VAR instruction changes character information to uppercase
before putting it into the variables.
quote = 'Knowledge is power.'
PARSE UPPER VAR quote word1 word2 word3
For more information about parsing instructions, see z/OS TSO/E REXX Reference.
PARSE VALUE ... WITH Instruction
The PARSE VALUE ... WITH instruction parses a specified expression, such as a
literal string, into one or more variable names that follow the WITH subkeyword. If
the literal string contains character information, it is not changed to uppercase.
PARSE VALUE 'Knowledge is power.' WITH word1 word2 word3
The PARSE UPPER VALUE instruction changes character information to uppercase
before assigning it to the variable names.
PARSE UPPER VALUE 'Knowledge is power.' WITH word1 word2 word3
Ways of Parsing
Parsing separates data by comparing the data to a template (or pattern of variable
names). Separators in a template can be a blank, string, variable, or number that
represents column position.
Blank
The simplest template is a group of variable names separated by blanks. Each
variable name gets one word of data in sequence except for the last, which gets the
remainder of the data. The last variable name might then contain several words and
possibly leading and trailing blanks.
PARSE VALUE 'Value
When there are more variables than data, the extra variables are set to null.
PARSE VALUE 'Value with Extra Variables.' WITH data1 data2 data3 data4 data5
/* word1 contains 'Knowledge' */
/* word2 contains 'is'
/* word3 contains 'power.'
/* word1 contains 'KNOWLEDGE' */
/* word2 contains 'IS'
/* word3 contains 'POWER.'
/* word1 contains 'Knowledge' */
/* word2 contains 'is'
/* word3 contains 'power.'
/* word1 contains 'KNOWLEDGE' */
/* word2 contains 'IS'
/* word3 contains 'POWER.'
with Blanks.' WITH pattern type
/* pattern contains 'Value'
/* type contains '
/* data1 contains 'Value'
/* data2 contains 'with'
/* data3 contains 'Extra'
/* data4 contains 'Variables.'
/* data5 contains ''
Parsing Data
*/
*/
*/
*/
*/
*/
*/
*/
*/
with Blanks.'
*/
*/
*/
*/
*/
*/
Chapter 7. Manipulating Data
89