How do I share the #AT code between an extension template and a control template? (#GROUP refuses #AT)

Applies to: ABC templates, Clarion version not named in the thread.

Problem

A template set has one extension template and one control template. They share about 90 percent of their code, which embeds code into two ABC Browse embeds, a data embed and so on. Putting the shared #AT statements into a #GROUP does not register: the template registry reports that #AT cannot be inside a #GROUP.

Solution

Ranked by what the posters said:

  1. Put everything between the #AT and its #END into a #GROUP and call that group from each #AT. A poster got good use of this on a similar template. The #AT lines themselves are still written twice.
  2. Put the #PREPARE and #AT statements into a group together with the common #PROMPTs, then duplicate those sections. This is the best one poster managed.
  3. Make a global template that does nothing unless it sees one of the local templates. The procedure templates then hold only the #PROMPTs (pulled in with #INSERT) and an #AT(%GatherSymbols). The global template sets its tokens in #AT(%GatherSymbols),PRIORITY(1), the procedure templates adjust them at PRIORITY(2), and if no adjustment happened the global template generates nothing more.

Caveats

  • The poster tried moving the code to a separate .tpw file and pulling it in with #INCLUDE; the IDE then failed with a GPF each time it registered the template, so he dropped that route.
  • The poster's own template was small (most #ATs held one or two lines), so he kept the duplicated code; the answers suit larger templates.
  • Option 3 was described by its author as not the most efficient and as an interesting route only for a template used in many procedures. Neither option was reported tested by the original poster.

Today (2026)

Likely unchanged: the registry rule on #AT inside #GROUP is a property of the template language. Not re-tested on a current build.

Sources: Arnor B. (Jan 2006, the question), Robert A., Mike H. (Jan 2006) in softvelocity.clarion.templates.