Advanced topics in parsing, Parsing multiple strings – IBM SC34-5764-01 User Manual

Page 233

Advertising
background image

When total=7 then new='purple'
When total=9 then new='orange'
When total=10 then new='green'
Otherwise new=var1

/* entered duplicates */

END
Say new; exit

/* Displays: "purple" */

Err:
say 'Input error--color is not "red" or "blue" or "yellow"'; exit

ARG converts alphabetic characters to uppercase before parsing. An example of ARG with the arguments
in the CALL to a subroutine is in section “Parsing Multiple Strings.”

PARSE ARG works the same as ARG except that PARSE ARG does not convert alphabetic characters to
uppercase before parsing.

PARSE EXTERNAL

Say "Enter Yes or No =====> "
parse upper external answer 2 .
If answer='Y'

then say "You said 'Yes'!"
else say "You said 'No'!"

PARSE NUMERIC

parse numeric digits fuzz form
say digits fuzz form

/* Displays: '9 0 SCIENTIFIC'

*/

/* (if defaults are in effect)

*/

PARSE PULL

PUSH '80 7'

/* Puts data on queue

*/

parse pull fourscore seven /* Assigns: fourscore='80'; seven='7' */
SAY fourscore+seven

/* Displays: "87"

*/

PARSE SOURCE

parse source sysname .
Say sysname

/* Displays:

"CICS"

*/

PARSE VALUE example is on page 203.

PARSE VAR examples are throughout the chapter, starting on page 204.

PARSE VERSION

parse version . level .
say level

/* Displays: "3.48" */

PULL works the same as PARSE PULL except that PULL converts alphabetic characters to uppercase
before parsing.

Advanced Topics in Parsing

This section includes parsing multiple strings and flow charts depicting a conceptual view of parsing.

Parsing Multiple Strings

Only ARG and PARSE ARG can have more than one source string. To parse multiple strings, you can
specify multiple comma-separated templates. Here is an example:

parse arg template1, template2, template3

Parsing

Chapter 15. Parsing

211

Advertising