![]() |
|
Published 1998-10-01 Printer-friendly version
Many people have a couple of false impressions regarding templates. First, they believe that procedure templates generate code into procedures, and global templates generate code into the main module. What people don't realize is that global templates can have a local effect on each and every procedure in an application. Secondly, templates may not generate code: they may simply affect the settings and actions of other templates in your application.
A "global" template is one that is populated into the Global Extensions window. It can use the #AT structure to generate code into any embed, which may occur at any time. This includes both global program and local procedure embeds. When it is actuated for a local embed, the global template can check the settings of the local procedure (including its procedure templates) to determine whether or not it wants to affect the procedure.
To create global templates, you must have a basic knowledge of embeds, prompts of other templates, and local template variables created by other templates. However, writing a global template is usually not any more difficult than writing a local procedure template.
The two main purposes of a global template are:
For example, you may want to make all required fields bold-white on red, or to bold strings with USE variables. This would require that your template generate code, because your template cannot change the value of built-in symbols (like %Control). Or you could change the [Close] button to [Cancel] each time a browse is called to select a record. Again, generated code would be need for execution at runtime.
Alternatively, a global template could be used to change settings throughout your application. A good example of this is to change all Step locators to Incremental locators. Finally, your global template can change the value of intermediate local variables of other templates. This enables you to change the actions of templates like the BrowseBox.
When necessary, you can use local procedure templates in concert with global templates to affect the actions of the global template. For example, you could write a local template to tell the global template to ignore the current procedure.
The thing to realize is that global templates can do almost anything that you can think of, and often much more than you realize.
Copyright © 1999-2008 by CoveComm Inc. All Rights Reserved. Reproduction in any form without the express written consent of CoveComm Inc., except as described in the subscription agreement, is prohibited.
Clarion Magazine ISSN 1718-9942
One year: $189
(includes all back issues since '99)
Renewals from $139
Two years: $289
Renewals from $239