FOR

Top  Previous  Next

Syntax

FOR variable = start TO end OPT step

FOR pData = EACH pList {AS type}

Description

The first form of FOR loops from start to end. The second iterates through a linked list.

Parameters

variable - Integer counter variable. Must be of type CHAR, INT, UINT, or WORD

start - Starting count of the loop.

end - Ending count of the loop.

step - Optional stepping value. Defaults to 1.

pData - Pointer to receive each data pointer of the list in turn.

pList - Linked list to iterate.

type - Automatic typecasting name.

Return value

N/A

Remarks

step can be a negative value in which case the loop will count backwards. The number of loops is inclusive of the end value so a start of 0 and an end of 10 will loop 11 times. To break out of a FOR/NEXT loop early you can use the BREAKFOR command.

The automatic typecasting name alleviates the need to use typecasting or the SETTYPE command on the returned data pointer.

See Also: NEXT, BREAKFOR

Example usages

FOR x = 1 to 10
PRINT x
NEXT x
 
FOR mydata = EACH mylist AS STRING
PRINT #mydata
NEXT