Applies to: the template language as discussed in February 2007; the thread names no Clarion version. The ABC window templates are used as the example.
Problem
A template generates #EMBED statements inside a #FOR loop. Each pass must produce its own embed point, not the same one repeated.
Solution
- Add the symbol attribute to the #EMBED statement:
#EMBED(identifier,descriptor),symbol. The embed is then tied to the value of the multi-valued symbol, so each loop value gets its own embed point. - Optionally add a TREE() attribute after the symbol for better visual support in the embed tree; it can carry embed-specific text.
- The symbols must hold their values when the #EMBED runs. A nested loop example from the thread:
#FOR(%pClassMethod)
#FOR(%pClassMethodPrototype)
#EMBED(%WindowManagerMethodCodeSection,''),%pClassMethod,%pClassMethodPrototype
#ENDFOR
#ENDFOR
- A loop is not required:
#FIXcan set a specific value, and the #EMBED that follows uses it. - For a full example the poster was pointed to the code around %ControlHandling in ABWINDOW.TPW, which nests embeds and uses the PRIORITY and TREE attributes.
Caveats
- The thread calls the generated-virtuals approach one of the more complex parts of the templates.
- The poster only thanked the answerers and did not report a test.
- Only the symbol attribute and the examples above are covered; no other uniqueness mechanism is discussed.
Today (2026)
Likely still valid; the shipped template source remains the best example. Not re-tested on a current build.
Sources: Chris B. (Feb 2007, the question), Lee W. (Feb 2007), Mike H. (Feb 2007) in softvelocity.clarion.templates.