10.4.2.11. SELECT~CASE~END_SELECT
10.4.2.11. SELECT~CASE~END_SELECT
Explanation | Evaluate the <Condition formula> value, and branch into the CASE statement that satisfies one condition of <Item>. If there is no CASE statement that satisfies <Item>, branch into the CASE ELSE statement. When meeting the next CASE statement, branch into the END_SELECT statement. When the EXIT SELECT statement is executed, immediately branch into the END_SELECT statement. | ||
Grammar | SELECT <Condition formula> CASE <Item>[,<Item>…] : [CASE ELSE] END_SELECT | ||
Parameter | Condition formula | Arithmetic formula, string formula. |
|
Item | [<Comparison operator>]<Condition formula> <Condition formula> TO <Condition formula> | The comparison operator or TO can be used only in the arithmetic formula | |
Comparison operator | <, >, <=, >=, <> | If failing to consider, take it as = | |
Example | Arithmetic comparison example | SELECT V3%*2 CASE 1,2,3,<0,<>-9 V4%=400 IF V3%=50 THEN EXIT SELECT ENDIF V5%=500 CASE 4 TO 6, 7, 8, 9 V4%=800 CASE 10 STOP CASE ELSE GOTO _ERR END_SELECT | |
String comparison example | SELECT V5$ CASE "ROBOT","HUMAN" V4%=400 CASE "DOG" V4%=800 CASE ELSE GOTO _ERR END_SELECT |