Nesting if statements

If statements can contain other if statements within them (nesting), as shown in this example.

value1 as integer = 0
value2 as integer = 0
value3 as integer = 0
value4 as integer = 0

do print ( value1 ) print ( value2 ) print ( value3 ) print ( value4 )
if value1 + value2 + value3 + value4 < 1000 if value1 < 100 value1 = value1 + 1 elseif value2 < 200 value2 = value2 + 1 elseif value3 < 300 value3 = value3 + 1 elseif value4 < 400 value4 = value4 + 1 endif endif
sync ( ) loop

When the program runs you will see value1 go from 0 to 100, then value2 will go from 0 to 200, then value3 will go from 0 to 300, finally value4 will go from 0 to 400. When all of these variables add up to 1000 the first if statement condition will be false, so nothing else happens with these variables.