Help / Control Flow

Control Flow

5 GRS reference entries.

if / else if / else

Purpose
Executes conditional branches.
Syntax
if <condition> then begin
    ...
end
else begin
    ...
end
Example
if vehicle.id = 1 then begin
    print "first vehicle" to log
end
else begin
    print "other vehicle" to log
end
Notes
The AutoMod-style two-line form is also accepted: write if (condition) or else if (condition) and put begin on the next line. In conditions = is comparison.
Related
comparison operators, and, or, not

while

Purpose
Repeats a block while its condition is true.
Syntax
while <condition> do begin
    ...
end
Example
set i = 0
while i < 5
begin
    inc i by 1
    print "i = ", i to log
end
Notes
The two-line form (while condition, then begin on the next line) is accepted.
Related
break, continue, inc

for each

Purpose
Iterates a list snapshot.
Syntax
for each <item> in <list> do begin
    ...
end
Example
for each v in Vehicle
begin
    print v to log
end
Notes
for each v in Vehicle iterates all OHT vehicles (OHT only). The list is evaluated once when the loop begins.
Related
while, break, continue

break

Purpose
Leaves the innermost while / for each loop.
Syntax
break
Example
while i < 10
begin
    inc i by 1
    if i = 5 then begin
        break
    end
end
Notes
Only valid inside a loop.
Related
while, for each, continue

continue

Purpose
Skips to the next iteration of the innermost loop.
Syntax
continue
Example
while i < 10
begin
    inc i by 1
    if i % 2 = 0 then begin
        continue
    end
    print i to log
end
Notes
Only valid inside a loop.
Related
while, for each, break