SELECT ... CASE ... END SELECT
- Logical_Expression1 ... Logical_ExpressionN
Optional. One or more expressions that evaluate to .T. (TRUE) or .F. (FALSE).
- Statements1 ... StatementsN
Optional. A set of one or more statements paired with a corresponding logical expression, to be executed if the logical expression evaluates to .T. (TRUE).
- Statements ... StatementsN
Optional. A set of one or more statements that execute in the default case, if no other statement evaluates to .T. (TRUE).
Conditional control structure comprised of one or more CASE statements.
SELECT ... CASE is a conditional control structure comprised of one or more CASE statements. The Logical Expression of each CASE statement is evaluated until a TRUE result is reached. The statements for the TRUE CASE are executed, and program flow continues after the end SELECT. The statements listed after the CASE else are executed as the default action if no other CASE expression is TRUE. Note : Because SELECT ... CASE spans multiple lines, it cannot be used in an expression. However, the CASE() function will achieve the same result, and may be used in an expression.
Associate a grade with a score. Any score below 60 is an F.
function test_grade as C(score as N) SELECT CASE score >= 90 grade = "A" CASE score >= 80 grade = "B" CASE score >= 70 grade = "C" CASE score >= 60 grade = "D" CASE else grade = "F" end SELECT test_grade = grade end function