An #EMBED in a code template is replicated at every instance of the template

Applies to: a code template used several times in one application; the thread names no Clarion version or chain.

Problem

A code template is placed more than once in an application. It contains an #EMBED statement. The code the user types into that embed point is replicated at each instance of the template instead of staying with one instance.

Solution

  1. Make the embed dependent on the Active Template Instance, so each instance gets its own embed point.
  2. Declare the embed symbol first, as a multi-valued symbol, in an #ATSTART block:
#ATSTART
  #DECLARE(%MyEmbed),MULTI
#ENDAT
  1. Then write the #EMBED with the instance as its dependency and a per-instance description, and include the MAP attribute:
#EMBED(%MyEmbed,'MyTemplate'),%ActiveTemplateInstance,%ActiveTemplateInstance['My Embed '],MAP(%MyEmbed,%ActiveTemplateInstance)
  1. Substitute your own text for the template name and the embed description inside the quotes.

Caveats

  • The original poster confirmed this was the answer, but said he did not yet fully understand why it works.
  • A second poster, new to templates, copied the skeleton into a #CODE template and found the embed points listed as Orphaned embeds. The thread has no reply to that, so the cause is not settled.
  • The code in the thread is quoted from a newsgroup post and wraps; check it against your own template source.

Today (2026)

Likely unchanged, since this is template language rather than IDE behaviour. Not re-tested on a current build.

Sources: Mike L. (Jul 2004, the question), Bo S. (Jul 2004), Helgard S. (Aug 2004) in softvelocity.clarion.templates.