SD - The Open Source, Multivalue, String, Database
The BEGIN CASE, CASE and END CASE statements provide conditional execution dependant on the result of expression evaluation.
Format:
BEGIN CASE
CASE expr
statement(s)
CASE expr
statement(s)
END CASE
Parameters: expr is an expression which can be resolved to a numeric value
statement(s) is a group of QMBasic statements. There may be any number of
statements in the group (including zero).
The expressions are evaluated in turn until one evaluates to true. The statements associated with that test expression are then executed and control passes to the statement following the END CASE. Only one of the statement groups is executed. If none of the test expressions evaluates to true, no statements are executed.
It is frequently useful to execute a default set of statements where no specific test expression results in non-zero result. This can be achieved by a case of the form
CASE 1
which makes use of the fact that 1 is the value of the boolean True. This must be the final element of the CASE statement.
Example:
N = DCOUNT(ITEMS, @VM)
BEGIN CASE
CASE N = 0
DISPLAY "There are no items"
CASE N = 1
DISPLAY "There is 1 item"
CASE 1
DISPLAY "There are " : N : " items"
END CASE
This program fragment displays a message indicating the number of values in the ITEMS variable. Note the use of the CASE 1 construct.
SD Basic Statements - BEGINCASE, CASE, ENDCASE
OpenQM 2.6.6 documentation for this command is available here. The OpenQM documentation may provide additional context for this command. However, some features in SD have been modified so the OpenQM information may not be 100% applicable to SD.