Danaher Motion
06/2005
BASIC Moves Development Studio
M-SS-005-03 Rev
E
31
After you have specified the variable or expression, list one or more values
or value ranges that the variable can take. There are four ways you can
specify cases:
Exact Value
Logical Condition
Range
Else
The syntax of Select…Case is:
Select Case
SelectExpression
{Case
Expression1
{
statements to be executed if SelectExpression = Expression1
}}
{Case
Expression2
{
statements to be executed if SelectExpression = Expression2
}}
{Case Is RelationalOperator
Expression3
{
statements to be executed if the condition is true
}}
{Case
Expression4
To
Expression5
{
statements to be executed if SelectExpression is between values
}}
{Case Else
{
statements to be executed if none of the above conditions are met
}}
End Select
where
SelectExpression is a Long, Double or String expression
in Case…To…, if Expression4 > Expression5, the case is
never true; no error is flagged.
Select…Case block. The following example puts all four types of cases
together:
Program
Dim N as Long
Select Case N
Case 0
Print "N = 0"
Case 1
Print "N = 1"
Case is >=10
Print "N >= 10"
Case is < 0 ‘No requirement for statements after Case
Case 5 TO 9
Print "N is between 5 and 9"
Case Else
Print "N is 2, 3, or 4"
End Select
End Program
For…Next
statements allow you to define loops in your program. The syntax
is:
For
counter
=
Start
To
End
{Step
Size
}]
{
Loop Statements
}
Next {
counter
}
where
If
Size
is not defined, it defaults to 1.
The loop is complete when the
counter
value exceeds
End
.
For positive
Size
, this occurs when
counter
>
End
. For
negative
Size
, when
counter
<
End
.
Counter
,
Start
,
End
, and
Size
may be Long or Double.