A select case
construct conditionally executes one block of constructs or statements depending on the value of a scalar expression in a select case
statement. This control construct can be considered as a replacement for computed goto
.
[name:] SELECT CASE (expr)
[CASE (case-value [, case-value] ...) [name]
block]...
[CASE DEFAULT [name]
block]
END SELECT [name]
where,
select case
construct (optional)Examples:
! simplest form of select case construct
select case(i)
case(:-1)
s = -1
case(0)
s = 0
case(1:)
s = 1
case default
print "Something strange is happened"
end select
In this example, (:-1)
case value is a range of values matches to all values less than zero, (0)
matches to zeroes, and (1:)
matches to all values above zero, default
section involves if other sections did not executed.