advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SELECT CASE Statement Details
  Summary  Details  Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 SELECT CASE testexpression
      CASE expressionlist-1
           [statementblock-1]
      [CASE expressionlist2
           [statementblock-2]]
      [CASE expressionlist-n
           [statementblock-n]]
      [CASE ELSE
           [statementblock-n]]
 END SELECT
 
 Usage Notes
   ■ If testexpression matches the expressionlist associated with a CASE
     clause, the statement block following that CASE clause is executed up
     to the next CASE clause or, for the last one, up to END SELECT. Control
     then passes to the statement following END SELECT.
 
   ■ If you use the TO keyword to indicate a range of values, the smaller
     value must appear first. For example, the statements associated with
     the line:
 
         CASE -1 TO -5
 
     are not executed if testexpression is -4. The line should be written
     as:
 
         CASE -5 TO -1
 
   ■ You can use a relational operator only when the IS keyword appears. If
     CASE ELSE is used, its associated statements are executed only if
     testexpression does not match any other CASE selections. It's a good
     idea to have a CASE ELSE statement in your SELECT CASE block to
     handle unforeseen testexpression values.
 
   ■ When there is no CASE ELSE statement and no expression listed in the
     CASE clauses matches testexpression, program execution continues at
     the statement following END SELECT.
 
   ■ You can use multiple expressions or ranges in each CASE clause. For
     example, the following line is valid:
 
         CASE 1 TO 4, 7 TO 9, 11, 13, IS > MaxNumber%
 
   ■ You can also specify ranges and multiple expressions for strings:
 
         CASE "everything", "nuts" TO "soup", TestItem$
 
     Note: CASE matches strings that are exactly equal to "everything," the
     current value of TestItem$, or that appear between "nuts" and "soup" in
     alphabetical order.
 
   ■ Strings are evaluated according to the ASCII values of their
     characters. Lowercase letters have larger ASCII values than uppercase
     letters, so this statement is true:
 
         nuts > Nuts > NUTS
 
   ■ If an expression appears in more than one CASE clause, only the
     statements associated with the first appearance of the expression are
     executed.
 
   ■ SELECT CASE statements can be nested. Each SELECT CASE statement must
     have a matching END SELECT statement.