![]() |
|
Published 1997-09-01 Printer-friendly version
"Code it the first time.... and if you are going to use it again, put it in a template." That should sound familiar, it is in the Clarion manual and you have probably heard it if you have been part of the Clarion community for more that a week. That sounds good eneough, but many long time Clarion coders have never read the templates and get along fine. Others get lost in the first few lines and would just rather put things in the embeds as they always have... or suffer the available functionality until 'one of the really smart ones' writes a new template or makes an extensiion available. Depending on the work load, experience level and the function, that may be all you want to do. But as those who have tried it will tell you, there is another level of excitement available when you put code in that first embed that YOU placed in the template(s) because YOU wanted it.
Who better to lay out the appetizers for the template writing feast than Tom Moseley. For those of you who do not recognize the name, Tom was the author of the Clarion Windows templates up through version 2.00. Since that time Tom has gone on to found The Moseley Group and Clarion Online. Among other things, The Moseley Group produces and sells the DET Templates that show the rest of us why some of the text field hooks were built into the CW dictionary, plus some other acts of legerdemain that can save time, money and effort during code generation and maintenance.
Tom took the time during DEVCON '97 to treat his audience to a sampling of tasty tidbits to whet anyone's appetite for template productivity. Here's a sample of what was on the menu.
Tom cautioned the group that writing successful templates or template additions was all about understanding the time relationships. At what point in the code generation cycle was your template code going to be needed to accomplish the desired end point. The times we need to be concerned about are :
With time in mind, Tom carried us on to some insights on symbols. Symbols are those key words proceeded by %'s that stand in for all the names we want to call things... that the templates can't know until... well, until we call them that; File names, and key names, and globals and so on. Tom reminded us that there are Single-Valued (like %Application) and Multi-Valued (%File, %Control) symbols and then pointed out that both of these may have dependencies... (FieldNames depend on FileNames). Tom then saved us all some sweat by telling us about FIX and FIND. Basically, they both set up the environment for a set of Symbols/Symbol dependents. The trick is, only use FIND with Files; if you use it with Procedures, your template code will be working in the wrong area of the APP tree... not good. Additionally, Tom pointed out that Symbols come in three varieties, Built-in's (in da box), User-defined (home made) and Prompts (hybrids of the first two, set by the template user.)
Tom explained one thing you may have wondered about in the templates. When there are Multi-Valued symbols like FileName the templates loop through them with a
#FOR %Symbol ... #ENDFOR
syntax. Ah... ha, looks like C, heh. Well, it helped me.
Tom moved on to give us some hints on embeds. The hint here was to remember that they are passive. And I quote, "Like and old girl friend... they just sit around waiting to be called." The deal here is that the template writer has got be be sure to get the name right. Wrong name... won't be found, won't get called. So study up on the #AT code and get the spelling right.
Tom left us with some hard won advice...
Sounds like a recipe for success. Now, where did I put that Template Language Reference and that to do list.
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