| **Navigation:**  [[templates.htm|Templates]] > [[tlrcontents.htm|Template Language Reference]] > Complete Alpha Listing >====== #FOR (generate code multiple times) {{c6h0068.jpg|C6H0068.jpg}} ====== | [[ fix fix a multi value symbol .htm|{{btn_prev_n.gif|Previous page}}]][[tlrcontents.htm|{{btn_home_n.gif|Return to chapter overview}}]][[ free free a multi valued symbol .htm|{{btn_next_n.gif|Next page}}]] | | || **#FOR(** //symbol// **)** [, **WHERE(** //expression// **)** ] [, **REVERSE** ] //     statements// **#ENDFOR** {{blk2blue.jpg|blk2blue.jpg}} | **#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 break out of a loop .htm|#BREAK]] ,[[ cycle cycle to top of loop .htm|#CYCLE]]