``

prev Menu next

SELECT CASE ☆
The block succeeding the CASE-line which contains the item that agrees with the value of the expression written at the SELECT-CASE-line shall be executed.
If no CASE-item agrees, the block succeeding the CASE-ELSE-line shall be executed.
Example.

    INPUT m
    SELECT CASE m
    CASE 1,3,5,7,8,10,12
       LET d=31
    CASE 4,6,9,11
       LET d=30
    CASE 2
       LET d=28
    CASE ELSE
       PRINT "?"
    END SELECT
    PRINT d
    END

More than one item can be written in a CASE-line punctuated by commas.
An item must consist of only constants.
An item is a constant, a constant TO a constant, or IS a comparison operator a constant.
Example.

    SELECT CASE 2*x-3
    CASE 0 TO 2
       PRINT "y"
    CASE IS <0, IS >2
       PRINT "n"
    END SELECT

The items are tested downward from the top. Once an item agrees, the rest CASE items are not tested.
If a CASE-ELSE-line is omitted, an exception of EXTYPE 10004 shall be raised when no item agrees.
Either a numeric expression or a string expression can be written in the SELECT-CASE-line.