Suppose you wanted to branch one way if b is 1, 7, 2037, or 5; and another way if otherwise. You could do it by:
But in this case, it would be simpler to list the numbers for which you want Statement1 to execute. You would do this with a case statement:
The general form of the case statement is:
The otherwise part is optional. When available, it differs from compiler to compiler. In many compilers, you use the word else instead of otherwise.
selector is any variable of an ordinal data type. You may not use reals!
Note that the lists must consist of literal values. That is, you must use constants or hard-coded values -- you cannot use variables.
<<< Previous | Table of Contents | Next >>> |