CASE


The CASE statement allows the programmer to execute a particular sequence of instructions based upon the results of a series of test expressions.

 

COMMAND SYNTAX

BEGIN CASE
CASE expression
    statement(s)
CASE expression
    statement(s)
.....
END CASE

 

SYNTAX ELEMENTS

The CASE structure is bounded by the BEGIN CASE and END CASE statements. Within this block, an arbitrary number of CASE expression statements may exist followed by any number of jBC statements. The expression should evaluate to a TRUE or FALSE result. At execution time, each expression is evaluated in order. If the expression returns a TRUE result, then the statements beneath it are executed. On completion of the associated statements, execution will resume at the first statement following the END CASE.

 

NOTES

A default action (to trap error conditions for instance) may be introduced by using an expression that is always TRUE, such as CASE 1. This should always be the last expression in the CASE block.

 

EXAMPLE

BEGIN CASE
CASE A = 1
    CRT "You won!"
CASE 1
    CRT "You came nowhere"
END CASE

A single comment is printed depending on the value of A. Note that if A is not 1 then the default CASE 1 rule will be executed as a "catch all".


jBC