407
CSE( ) Function
Case Compare
Format
CSE(expression[$],compare1[$],compare2[$] ...[,ERR=stmtref])
Where:
compare1[$]
Comma-separated list of numeric or string expressions for
compare2[$] ... comparison with expression[$].
expression[$]
Numeric or string expression to be used for comparison.
stmtref
Program line number or label to transfer control to.
Returns
Integer representing the sequence number of a match, or 0 zero if no match.
Description
The CSE( ) function is used to compare an expression with a series of values. If the
expression has a match, the resulting number will point to the location of the
matched value in the series; i.e., if expression matches the 5th value in the compare
series, then CSE( ) returns 5. If no match is found, CSE( ) returns 0.
Examples
1000 INPUT X$
1010 ON CSE(CTL,1,2,1000,1020,1030) GOTO NOFKY,FK1,FK2,QRY_CST,DEL_CST,ADD_CST
In the example above, if the value of CTL is 1000 then the CSE( ) function returns 3; if
the value of CTL is 1030, then 5 is returned; etc.
The example below shows strings in the comparison.
1010 ON CSE(TEST$,"ANTIDISESTABLISHMENTARIANISM","DOG","CAT","PIG") GOTO 1000,
1010:2000,3000,4000
See Also