BASIC Moves Development Studio
06/2005
Danaher Motion
32 Rev
E
M-SS-005-03l
For example:
For I = 2 TO 5
Print "I = " I 'Prints 2, 3, 4, 5
Next I
For I = 4 TO 2 STEP –0.5
Print "I = " I 'Prints 4.0, 3.5, 3.0, 2.5, 2.0
Next
While…End While
allows looping dependent on a dynamic condition. For
example, you may want to remain in a loop until the velocity exceeds a
certain value.
The syntax of
While
is:
While
Condition
{
statements to execute as long as condition is true
}
End While
where
The condition is evaluated before any statements are
executed. If the condition is initially false, no statements are
executed.
Statements are optional. If none are included,
While…End
While
acts as a delay.
You can have any number of statements (including zero) to
be executed.
For example:
Program
While A2.VelocityFeedback < 1000
Print "Axis 2 Velocity Feedback still under 1000"
End While
End Program
Using the
While
or
Do…Loop
, the CPU repeatedly executes the
While
block (even if the block is empty). This is sometimes a problem. These
commands do not relinquish system resources to other tasks. If you want to
free up CPU resources during a
While
block or
Do…Loop
, include the
Sleep
command within the block as follows:
Program
While A1.VCmd < 1000
Sleep 1
End While
End Program
The
Do...Loop
is similar to
While
except that the statement block is
executed before the first evaluation of the condition. With the
Do...Loop
, the
statement block are always executed at least once.
Do...Loop
also allows an
option on the condition. Use
While
to execute while the condition is true, or
Until
to execute while the condition is false. The syntax of the
Do...Loop
is:
Do
{
statements
}
LOOP
While|Until Condition
where:
The statements are executed at least once.
Statements are optional. If none are included,
Do...Loop
acts
as a delay.