The for loop variable needs to be of ordinal data type.
The for-loop variable will increase by one if using for k := 1 to 10 do
If the first value is higher than the second value the loop will not execute.
The for-loop variable will decrease by one if using for k := 10 downto 1 do
If the first value is lower than the second value the loop will not execute.
These values can be variables - for k := iLower to iUpper do
These two values may also be calculations or functions as long as their output is of ordinal data type - for k := 1 to Round(iNum/2) do OR for k := 1 to iNum div 2 do
NEVER change any variable in the for loop header line inside the loop.
The for loop variable may NEVER be global.
If there is more than one line of code in the for-loop to be executed you will need a begin and an end. Place a comment after the end indicating it belongs to the for-loop - end;//for
If you need to calculate the average of numbers inside a for-loop you need to initialise the running total (iTotal) and the counter (iCount) above the loop. This allows the button to be clicked twice but will still calculate correctly.
Any other structure can be used inside the for-loop, like if and case statements.
Loops can be used to create animations if you have the separate gif files for a picture.