Data Sheet

MicroBasic Language Reference
Advanced Digital Motor Controller User Manual 201
The following example illustrates how to declare Integer variable:
Dim intVar As Integer
Arrays declaration uses a different syntax, where you should specify the array length be-
tween square brackets []. Array length should be integer value greater than 1.
Dim arr[n] As { Integer | Boolean }
The following example illustrates how to declare array of 10 integers:
Dim arr[10] As Integer
To access array elements (get/set), you may need to take a look to Arrays section (see Ar-
rays on page 198).
Variable and arrays names should follow specification stated in the Variables section (see
Variables on page 198).
If...Then Statement
Line If
If <condition> Then <stmt> [Else <stmt>]
Block If
If <condition> [Then]
<block>
[ElseIf <condition> [Then]
<block>]
[ElseIf <condition> [Then]
<block>]
...
[Else
<block>]
End If
An If...Then statement is the basic conditional statement. If the expression in the If
statement is true, the statements enclosed by the If block are executed. If the expres-
sion is false, each of the ElseIf expressions is evaluated. If one of the ElseIf expres-
sions evaluates to true, the corresponding block is executed. If no expression evaluates to
true and there is an Else block, the Else block is executed. Once a block finishes execut-
ing, execution passes to the end of the If...Then statement.
The line version of the If statement has a single statement to be executed if the If ex-
pression is true and an optional statement to be executed if the expression is false. For
example:
Dim a As Integer
Dim b As Integer
a = 10
b = 20
‘ Block If statement.
If a < b Then
a = b