#FOR (generate code multiple times) 

Top  Previous  Next

 

#FOR( symbol ) [, WHERE( expression ) ] [, REVERSE ]

    statements

#ENDFOR

#FOR

Loops through all instances of a multi-valued symbol.

symbol

A multi-valued symbol.

WHERE

Specifies the statements in the #FOR loop are executed only for those instances of the symbol where the expression is true.

expression

An expression that specifies the condition for execution.

REVERSE

Specifies the #FOR loops through the instances of the symbol in reverse order.

statements

Target and/or Template Language statements.

#ENDFOR

Terminates the #FOR structure.

#FOR is a loop structure which generates its statements once for each value contained in its symbol during source code generation. If there are no values in the symbol, no code is generated. #FOR must be terminated by #ENDFOR. If there is no #ENDFOR, an error message is issued during Template file pre-processing. A #FOR loop may be nested within another #FOR loop.

The #FOR loop begins with the first instance of the symbol (or last, if the REVERSE attribute is present) and processes through all instances of the symbol--it is not affected by any #FIX statements. If the WHERE attribute is present, the #FOR statements are executed only for those instances of the symbol where the expression is true. This creates a conditional #FOR loop.

Since #FOR is a loop structure, the #BREAK and #CYCLE statements may be used to control the loop. #BREAK immediately terminates #FOR loop processing and continues with the statement following the #ENDFOR that terminates the #FOR. #CYCLE immediately returns control to the #FOR statement to continue with the next instance of the symbol.

Example:

#FOR(%ScreenField),WHERE(%ScreenFieldType = 'LIST')

 #INSERT(%ListQueueBuild)             #!Generate only for LIST controls

#ENDFOR

 

See Also:     #BREAK ,#CCLE