Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Simple templates for parsing into words z/OS TSO/E REXX Reference SA32-0972-00 |
|
Here is a parsing instruction:
The template in this instruction is: var1 var2 var3.
The data to parse is between the keywords PARSE VALUE and
the keyword WITH, the source string time
and tide. Parsing divides the source string into blank-delimited
words and assigns them to the variables named in the template as follows:
In this example, the source string to parse is a literal string, time
and tide. In the next example, the source string is a variable.
(PARSE VALUE does not convert lowercase a–z in the source string to uppercase A–Z. If you want to convert characters to uppercase, use PARSE UPPER VALUE. See Using UPPER for a summary of the effect of parsing instructions on case.) All of the parsing instructions assign the parts of a source string into the variables named in a template. There are various parsing instructions because of differences in the nature or origin of source strings. (See Parsing instructions summary for a summary of all the parsing instructions .) The PARSE VAR instruction is similar to PARSE VALUE
except that the source string to parse is always a variable. In PARSE
VAR, the name of the variable containing the source string follows
the keywords PARSE VAR. In the next example, the
variable stars contains the source string. The template
is star1 star2 star3.
All variables in a template receive new values. If there
are more variables in the template than words in the source string,
the leftover variables receive null (empty) values. This is true for
all parsing: for parsing into words with simple templates and for
parsing with templates containing patterns. Here is an example using
parsing into words.
If there are more words in the source string than variables
in the template, the last variable in the template receives all
leftover data. Here is an example:
Parsing into words removes leading and trailing blanks
from each word before it is assigned to a variable. The exception
to this is the word or group of words assigned to the last variable. The last variable
in a template receives leftover data, preserving extra leading
and trailing blanks. Here is an example:
In the source string, Earth has two leading blanks. Parsing removes both of them (the word-separator blank and the extra blank) before assigning var3='Earth'. Mars has three leading blanks. Parsing removes one word-separator blank and keeps the other two leading blanks. It also keeps all five blanks between Mars and Jupiter and both trailing blanks after Jupiter. Parsing removes no blanks if the template contains only
one variable. For example:
|
Copyright IBM Corporation 1990, 2014
|