basic.case Statement/BASIC Program

basic.case

Command basic.case Statement/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description delineates a conditional case construct.

Only the statements following the first "true" case statement are executed. Upon completion of these statements program execution continues immediately following the "end case" statement.

If all "case" statements evaluate false, program execution is continued at the first statement after the "end case".

A "case 1" statement always evaluates true and is used as the last case statement to be processed only when all previous case statements evaluate to false.

The "case" statement is equivalent to nested "if" expressions as follows:

if logical.expression then
{statement{s}}
end else
if logical.expression then
{statement{s}}
end
end

The statements between "case" statements are executed if the expression associated with the case evaluates to true. If the expression evaluates to false, the statements are not executed.
Syntax begin case
case logical.expression
{statement{s}}
.
case logical.expression
{statement{s}}
.
.
end case
Options
Example
begin case  
* check for operators response
case response = "p"
  printer on
case response = "s"
  echo off
case 1
  crt "response must be 'p' or 's'"
end case

In this example, if the response is "p", the "printer on" 
statement is issued. The program would then branch to the next statement after 
"end case". The "case 1" is executed only if response is 
neither "p" nor "s".
Purpose
Related basic.statements
basic.end.case
basic.if
basic.match
basic.logical.expressions
basic.begin.case
branching