Example Using SELECT/WHEN/OTHERWISE/END
/******************************** REXX *****************************/
/* This exec receives input with a person's age and sex. In
*/
/* reply it displays a person's status as follows:
*/
/*
BABIES
- under 5
*/
/*
GIRLS
- female 5 to 12
*/
/*
BOYS
- male 5 to 12
*/
/*
TEENAGERS - 13 through 19
*/
/*
WOMEN
- female 20 and up
*/
/*
MEN
- male 20 and up
*/
/*******************************************************************/
PARSE ARG age sex .
SELECT
WHEN age < 5 THEN
/* person younger than 5
*/
status = 'BABY'
WHEN age < 13 THEN
/* person between 5 and 12
*/
DO
IFsex = 'M' THEN
/* boy between 5 and 12
*/
status = 'BOY'
ELSE
/* girl between 5 and 12
*/
status = 'GIRL'
END
WHEN age < 20 THEN
/* person between 13 and 19
*/
status = 'TEENAGER'
OTHERWISE
IFsex = 'M' THEN
/* man 20 or older
*/
status = 'MAN'
ELSE
/* woman 20 or older
*/
status = 'WOMAN'
END
SAY 'This person should be counted as a' status '.'
Each SELECT must end with an END. Indenting each WHEN makes an exec
easier to read.
Exercises - Using the SELECT/WHEN/OTHERWISE/END
Instruction
"Thirty days hath September, April, June, and November; all the rest have
thirty-one, save February alone ..."
Write an exec that provides the number of days in a month. First have the exec ask
the user for a month specified as a number from 1 to 12 (with January being 1,
February 2, and so forth). Then have the exec reply with the number of days. For
month "2", the reply can be "28 or 29".
ANSWER
Using Conditional Instructions
46
z/OS V1R1.0 TSO/E REXX User’s Guide
Содержание TSO/E REXX
Страница 1: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Страница 2: ......
Страница 3: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Страница 10: ...viii z OS V1R1 0 TSO E REXX User s Guide ...
Страница 12: ...x z OS V1R1 0 TSO E REXX User s Guide ...
Страница 14: ...xii z OS V1R1 0 TSO E REXX User s Guide ...
Страница 18: ...xvi z OS V1R1 0 TSO E REXX User s Guide ...
Страница 20: ...2 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 58: ...Tracing Expressions with the TRACE Instruction 40 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 78: ...60 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 86: ...Built In Functions 68 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 128: ...Issuing Other Types of Commands from an Exec 110 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 136: ...Debugging Execs 118 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 170: ...Protecting Elements in the Data Stack 152 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 201: ...Part 3 Appendixes Copyright IBM Corp 1988 2001 183 ...
Страница 202: ...184 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 222: ...Using Variables 204 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 226: ...208 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 238: ...220 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 241: ......