Data Sheet

MicroBasic Scripting
202 Advanced Digital Motor Controller User Manual V1.8, August 28, 2017
Else
b = a
End If
‘ Line If statement
If a < b Then a = b Else b = a
Below is an example where ElseIf takes place:
If score >= 90 Then
grade = 1
ElseIf score >= 80 Then
grade = 2
ElseIf score >= 70 Then
grade = 3
Else
grade = 4
End If
For...Next Statement
Micro Basic contains two types of For...Next loops:
Traditional For...Next:
Traditional For...Next exists for backward compatibility with Basic, but it is not rec-
ommended due to its inefficient execution.
Traditional For...Next is the same syntax as Basic For...Next statement.
C-Style For...Next:
This is a new style of For...Next statement optimized to work with Roboteq control-
lers and it is recommended to be used. It is the same semantics as C++ for loop,
but with a different syntax.
For <var> = <expression> AndWhile <condition> [Evaluate
<stmt>]
<block>
Next
The c-style for loop is executed by initialize the loop variable, then the loop contin-
ues while the condition is true and after execution of single loop the evaluate state-
ment is executed then continues to next loop.
Dim arr[10] As Integer
For i = 0 AndWhile i < 10
arr[i] = -1
Next
The previous example illustrates how to initialize array elements to -1.
The following example illustrates how to use Evaluate to print even values from
0-10 inclusive:
For i = 0 AndWhile i <= 10 Evaluate i += 2
Print(i, “\n”)
Next