to
Purpose
Separates the start and end values in a FOR loop
Description
The value before this is the start value of the index variable and the one after is the end value. The loop is executed until the value of the loop index variable goes from the start value to one step before the end value in increments of step
Syntax
for index = start to end loop ... repeat // Loop over values
for index = start to end step step loop ... repeat // Loop over values with step
Arguments
index loop index variable
start start value of index
end end value of index (loop is not executed with this value)
step amount to change index variable (default is one)
Example
// Draw 100 random boxes
clear()
for i = 1 to 100 loop
// Pick random colour
col = { random( 101 ) / 100, random( 101 ) / 100, random( 101 ) / 100, random( 101 ) / 100 }
x = random( gWidth() )
y = random( gHeight() )
width = random( gWidth() / 4 )
height = random( gHeight() / 4 )
outline = random( 2 )
box( x, y, width, height, col, outline )
update()
repeat
// Wait 3 seconds
sleep( 3 )
Associated Commands