AKD BASIC User Guide | 6 AKD BASIC Parameters, Operators, Statements
6.1.17 Select Case
General Information
Type Statement
Description
Select Case executes one of several statement blocks depending upon the
value of an expression.
Units N/A
Range N/A
Default
Value
N/A
Data Type N/A
Start Ver-
sion
TBD
Description
Select Case executes one of several statement blocks depending upon the value of an expres-
sion. The test-expression must evaluate to a numeric or floating-point value. There may be as
many Cases in the Select Case statement as you want. There can only be one Case Else and
it must be the last case in the sequence. The Case Else statement block is executed if all other
tests fail.
Select Case statements where the expression-lists are integer constants are executed more
quickly at run-time.
Example
This example prints out information about the numbers between 1 and 20.
Main
dim x as integer
for x = 1 to 20
print x;" is ";
select case x
case 1, 3, 5, 7, 9
print "Odd"
case 4, 8
print "4 or 8"
case 12 to 18
print "between 12 and 18"
case else
print "other"
end select
next
End Main
Related Topics
If...Then...Else
115 Kollmorgenâ„¢ | March 30, 2012