z/OS TSO/E CLISTs
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Using SELECT with a test expression (compound SELECT)

z/OS TSO/E CLISTs
SA32-0978-00

If you include a test expression on the SELECT statement, the CLIST compares the test expression to the expressions on the WHEN clauses. On each WHEN clause, you can specify multiple expressions, or a range of values by using a colon (:) between the low and high values in the range. You can combine expressions and ranges on a WHEN clause by using the operator OR or |.

If a test expression matches a value or falls within a range of values in a WHEN expression, the CLIST executes the action for that WHEN clause, then passes control to the END statement.

For example, in the following SELECT statement, the CLIST executes the action of the first WHEN clause because the test expression (5) falls within the range of values 4:6 on that WHEN clause:
SELECT 5
  WHEN (3 | 7 | 4:6)       action...
  WHEN (9 | &A + &Z)       action...
END

If no WHEN expressions satisfy the test expression, the CLIST executes the OTHERWISE action, if any.

For example, the following CLIST uses a SELECT statement to invoke other CLISTs that print quarterly reports. The CLIST bases its selection on a test expression (the number of the month) that the invoker supplies. When the number of the month falls within a certain range, the CLIST prints the appropriate report. Otherwise, the CLIST writes an error message.
PROC 1 MONTH
SELECT (&MONTH)
  WHEN (1:3)       %FIRSTQTR
  WHEN (4:6)       %SECNDQTR
  WHEN (7:9)       %THIRDQTR
  WHEN (10:12)     %FORTHQTR
  OTHERWISE  WRITE The month must be a number from 1 to 12.
END

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014