TACL Reference Manual
Built-In Functions and Variables
HP NonStop TACL Reference Manual—429513-018
9-40
#CASE Built-In Function
•
You cannot use square brackets in a label-num; no evaluation takes place
between the vertical bars.
•
If neither a matching label-num nor OTHERWISE is present, an error occurs.
Examples
1. This macro accepts an argument. If the argument is 0, the macro writes Zero; if the
argument is 1, the macro writes One, and so on.
[#CASE %1%
| 0 | #OUTPUT Zero
| 1 | #OUTPUT One
| 2 | #OUTPUT Two
| 3 | #OUTPUT Three
| 4 | #OUTPUT Four
| 5 | #OUTPUT Five
| 6 | #OUTPUT Six
| 7 | #OUTPUT Seven
| 8 | #OUTPUT Eight
| 9 | #OUTPUT Nine
| OTHERWISE | #OUTPUT %1% is not a digit.
]
2. This example illustrates the use of a space-separated list as a label:
[#CASE %1%
| 0 2 4 6 8 | #OUTPUT Even
| 1 3 5 7 9 | #OUTPUT Odd
| OTHERWISE | #OUTPUT Isn't a digit
]
3. This example shows how multiple lines can be used as option text for a label:
[#CASE %1%
| 1 3 5 7 9 | #OUTPUT Odd
#OUTPUT Prime
| 0 2 4 6 8 | #OUTPUT Even
[#IF [#MATCH %1% 2] |THEN|
#OUTPUT Prime]
|OTHERWISE| #OUTPUT Not a digit
]