📖⚡FOR

Repeat a section of code a fixed number of times.

 

Syntax

FOR Variable = StartValue TO EndValue [STEP StepAmount]

  COMMANDS

NEXT

Example

FOR B0 = 0 TO 7

  HIGH B0

NEXT


 

' FOR..NEXT Example
' For1.txt
' Kic8 

  ' We will execute our code 5 times. 
  ' Toggle a pin each time.
  
DO

  ' toggle an output pin 5 times
  FOR B0 = 1 TO 5

    TOGGLE 0

  NEXT

LOOP

To quit a FOR..LOOP before the count is finished, use the EXIT Statement

Example:

 

' EXIT (FOR..NEXT) Example
' ForExit.txt
' Kic8 

  ' We will execute our code 5 times. 
  ' Toggle a pin each time.
  ' Exit on the second count

DO

  FOR B0 = 0 TO 5

    ' 	Quit early
    IF B0 = 2 THEN EXIT

    TOGGLE 0

  NEXT

LOOP

Related Commands:

 

todo:

Tutorials: FOR..NEXT