Command group | Flag affected | Reversible | Execute on client | Platform(s) |
---|---|---|---|---|
Constructs | NO | NO | YES | All |
Case constant-value or expression
The Case statement is part of a Switch construct that chooses one of an alternative set of options. The options in a Switch construct are defined by the subsequent Case commands. The Case command takes either a constant, field name, single calculation, or a comma-separated series of calculations. You must enclose string literals in quotes. Date values must match the date format in #FDT.
You can use the Break to end of switch command to jump out of the current Case statement and resume method execution after the End Switch command. Note you cannot use the Break to end of loop command to break out of a Switch construct.
# Show the direction lPosition equals. eg. if lPosition equals 3 show 'South' in the ok message
Switch lPosition
Case 1
Calculate lDirection as 'North'
Case 2
Calculate lDirection as 'East'
Case 3
Calculate lDirection as 'South'
Case 4
Calculate lDirection as 'West'
End Switch
OK message {Position [lCount] = [lDirection]}
# Multiple conditions can be used in a comma-separated list to one Case statement.
# Default is used to specify commands that should run if the value is not one of
# those specified in the Case statements
Switch lDirection
Case 'North','South'
OK message {The direction is North or South}
Case 'East','West'
OK message {The direction is East or West}
Default
OK message {The direction is Unknown} ## # lDirection is none of the above
End Switch