Generating a whole function from a template instead of adding an extension to a hand-made Source procedure

Applies to: posted in the c55ee group (2003); the answers name #PROCEDURE, #PROTOTYPE and a global #AT example, with no version limit.

Problem

A developer had an extension template that generates a function from the current dictionary. To use it he had to create a Source procedure by hand, type its prototype and parameters, and only then add the extension. He wanted one template that does all of it, ideally one that could be added to an application and create (and perhaps export) the procedure.

Solution

  1. Convert the extension template to a procedure template. The thread points to #PROCEDURE in the online help.
  2. Add #PROTOTYPE to the procedure template so the prototype and parameters come from the template, not from typing them into a Source procedure.
  3. Study a simple procedure template you already know. Open its .tp? source file and copy its structure; having written the extension, most of the work is behind you.
  4. If the function belongs in a separate module, a second poster's pattern generates it from global embeds: add the file with #PROJECT in %CustomGlobalDeclarations, declare it in %GlobalMap with a MODULE block, and let a #GROUP (called with #INSERT) write the module text.
#AT(%CustomGlobalDeclarations)
#PROJECT('MyModule.CLW')
#ENDAT
#AT(%GlobalMap)
#INSERT(%GenerateMyModule)
MODULE('MyModule.CLW')
...prototypes...
End
#ENDAT

Caveats

  • The thread gives no complete working template; the original poster only said the example would help.
  • The group call in the example is a fragment from a second poster's own template, shown from memory of an older example.
  • Whether the generated procedure can also be exported from the application was not answered.

Today (2026)

Likely still the right route, since #PROCEDURE and #PROTOTYPE are part of the template language. Not re-tested on a current build.

Sources: Todd W. (Jan 2003, the question), Edward L., David G. (Jan 2003) in softvelocity.products.c55ee.