Data Sheet
dScript
dScript User Manual v2.15
do loop
The do loop will execute forever:
do
statements
loop
Optionally the do loop can have conditional tests at the beginning or end of the loop (but not
both).
The variations for the do loop command are:
do [statements] loop
do while <condition> [statements] loop
do until <condition> [statements] loop
do [statements] loop while <condition>
do [statements] loop until <condition>
An example:
A = 0
do
A = A + 1
loop while A<100
The difference between putting the conditional at the beginning or end of the loop is if the
conditional test (while or until) is placed after the loop command the loop will always be
executed at least once, even if the test is false. Placing the test before the do means the loop
does not get executed if the condition is false.
A = 5
do while A<3 ; this test is false
A = A + 1 ; so this command never gets executed
loop
do
A = A + 1 ; this command will get executed once
loop while A<3 ; even though this test is false
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
27