Loading...
 

case

case

case

Stack
Stack Position Description
Stack(In) Top Value
Stack(Out) Top -

With this instruction a construction of the form begins:

case
S1: S11 S12 ... S1k
S2: S21 S22 ... S2l
. . .
Sn: Sn1 Sn2 ... Snm
default: Sd1 Sd2 ...
endCase

The evaluation corresponds exactly to the execution of the equivalent instruction sequence:

Var(tmp)
-> tmp  // Wert vom Stack-Top
tmp S1 =  // Test 1
if { 
  S11 S12 ... S1k
} else { 
  tmp S2 =  // Test 2
  if { 
    S21 S22 ... S2l 
  }
  . . .
  else { 
    tmp Sn =  // Test n
    if { 
      Sn1 Sn2 ... Snm
    } else { // default
      Sd1 Sd2 ...
    }
  }
}

For S1 ... Sn there must be statements that bring a value to the stack (usually constants or variables). InstantView® compares these values with the value that 'case' finds on the stack top ( = if). When the test condition is met for the first time - the ith test returns TRUE - the associated statements Si1, Si2, ... are executed. If the result of all tests (Test1, ..., Testn) is FALSE, the sequence Sd1, Sd2 ... is executed, regardless of the position of the default branch. The default branch may also be missing. A case branch can be preceded by several conditions(case label).

Note: case constructions can be nested to depth 5.

Examples