Executes the first set of commands whose conditional expression evaluates to true (.T.).

DO CASE
   CASE lExpression1 
   [Commands]
   [CASE lExpression2 
   [Commands]]
   ...
   [CASE lExpressionN 
   [Commands]]
   [OTHERWISE 
   [Commands]]
ENDCASE

Parameters

CASE lExpression1 Commands...

When the first true (.T.) CASE expression is encountered, the set of commands following it is executed. Execution of the set of commands continues until the next CASE or ENDCASE is reached. Execution then resumes with the first command following ENDCASE.

If a CASE expression is false (.F.), the set of commands following it up to the next CASE clause is ignored.

Only one set of commands is executed. These are the first commands whose CASE expression evaluates to true (.T.). Any succeeding true (.T.) CASE expressions are ignored.

OTHERWISE Commands

If all of the CASE expressions evaluate to false (.F.), OTHERWISE determines if an additional set of commands is executed.

  • If you include OTHERWISE, the commands following OTHERWISE are executed and execution skips to the first command following ENDCASE.

  • If you omit OTHERWISE, execution skips to the first command following ENDCASE.

Expand imageRemarks

Expand imageExample

Expand imageSee Also