>>-SELECT--+-------------+-;-------------------------------------> +-LABEL--name-+ +------------------------------------------------------+ V | >----WHEN--expression--+---+--THEN--+---+--instruction--;-+------> +-;-+ +-;-+ >-+------------------------------------------+-END-+--------+-;->< +-OTHERWISE--+---+--+--------------------+-+ +--name--+ +-;-+ | +----------------+ | | V | | +---instruction--;-+-+
0
or 1
. If the result is 1
, the instruction following the associated THEN (which can be a complex instruction such as IF, DO, LOOP, or SELECT) is processed and control is then passed to the END. If the result is 0
, control is passed to the next WHEN clause.
1
, control is passed to the instructions, if any, after OTHERWISE. In this situation, the absence of an OTHERWISE produces an error, however, you can omit the instruction list that follows OTHERWISE.
Example 2.41. Instructions - SELECT
balance=100 check=50 balance = balance - check Select when balance > 0 then say "Congratulations! You still have" balance "dollars left." when balance = 0 then do say "Warning, Balance is now zero! STOP all spending." say "You cut it close this month! Hope you do not have any" say "checks left outstanding." end Otherwise do say "You have just overdrawn your account." say "Your balance now shows" balance "dollars." say "Oops! Hope the bank does not close your account." end end /* Select */ /
0
or 1
. The list of expressions is evaluated left-to-right. Evaluation will stop with the first 0
result and 0
will be returned as the condition result. If all of the subexpressions evaluate to 1
, then the condition result is also 1
.
Example 2.42. Instructions - SELECT
select when answer~datatype('w'), answer//2 = 0 Then say answer "is even" when answer~datatype('w'), answer//2 = 1 Then say answer "is odd" otherwise say answer "is not a number" end
select when answer~datatype('w') & answer//2 = 0 Then say answer "is even" when answer~datatype('w') & answer//2 = 1 Then say answer "is odd" otherwise say answer "is not a number" end
0
(.false).