An extension template writes empty external files when the Embeditor is opened: how to detect Embeditor generation

Applies to: a template-language question posted in the Clarion 10 group; the thread does not name the template chain. The two newer symbols are described as arriving in a future version.

Problem

An extension template generates a couple of external files and works. When the poster opens the Embeditor (and maybe the embed tree), the files are generated again and come out completely empty. He remembered there was a way for a template to tell that the generation was triggered by opening the Embeditor.

Solution

  1. Test the symbol %EditProcedure; it is set when the Embeditor is generating:
#IF(%EditProcedure)
#!this is the Embeditor
#ELSE
#!this is generation in the source file
#END
  1. Or compare %GenerateMode against an exact value. The thread lists 'SOURCE', 'PWEE' (the embed editor) and 'UTILITY', plus others such as 'EMBED' that are not used in generation, so always check for the exact match:
#IF(%GenerateMode = 'SOURCE')
#ELSIF(%GenerateMode = 'PWEE')
#ENDIF
  1. The reply says special symbols were to be added in a future version: %GenerateSourceView and %GenerateEmbeditorView each return 1 when generating in the source file or in the Embeditor, and blank otherwise.
  2. Put the file-writing statements only in the source-generation branch.

A further tip from the thread: a #$ line is shown in the Embeditor window only and can carry hints about where code belongs, for example a #$!FYI: ... line placed between two #EMBED statements.

Caveats

  • The poster thanked the replier for the first answer; he did not report the result of his own template.
  • The thread does not say in which Clarion build the two newer symbols first appear.
  • The #$ text is displayed in the Embeditor only; it is not generated into the source.

Today (2026)

Likely unchanged for %EditProcedure and %GenerateMode; not re-tested. Check the template language help of your build for %GenerateSourceView and %GenerateEmbeditorView before relying on them.

Sources: Arnor B. (Feb 2019, the question), Diego B. (SoftVelocity) (Feb 2019), Carl (Feb 2019) in sv.clarion.clarion10.