![]() |
|
Published 1998-02-01 Printer-friendly version
Over the past issues, several templates have been shared in the Simply Clarion column. These include:
Now that the new ABC templates are out you may want to know if these templates will work with the ABC templates. I know I wanted to know this. More important, you may want to develop a strategy for converting the wonderful templates you write to ABC. Let me share with you what I did.
As you know, templates are used to generate pieces of code consistently. Once the template is built, instead of many lines of code, you insert a template, possibly answer a few questions, and continue on your way without worrying about whether the syntax is correct. Prior to building the template, you may have had code you found yourself repeating and you said to yourself, this is a good candidate for a template.
To test the templates with the ABC, Ive followed this procedure backwards.
First I created a small test application where I could use each of the templates. Since the function of the application was to exercise the templates, I could call the file error template, with an appropriate message, even though there was no file error. Testing out this application took a few moments. After all, it was using previously tested embeds.
For each of the procedures I used to test the templates, I created a Source procedure. I copied the appropriate source code created during compilation in Step 1 into these procedures. I reran a second set of tests using both template generated and non-template generated code. The tests were identical. I then removed the original, template-generated procedures. This gave me an application with no simple templates in it, but which had the identical functionality. Listings of each of the appropriate procedures were produced these would be the before code.
I then ran the application modified in Step 2 through the application converter. Tension was building to see what kind of magic this would perform. Of course, I recompiled and retested. Same results. So far, so good.
The next step was to analyze the code created in step 3. Listings were produced of the appropriate procedures and compared with the listings produced in step 2. This produced some surprises. Good ones.
In most of the cases, the code was exactly the same. Since the functions being performed were fairly simple, this made sense. For example, several of the templates use the MESSAGE function. Since this function transfers straight across, the created syntax should be the same. This led to
Many of the templates could be ported over with little changing. One change, however, does need to be made. Since there are now families of templates, the #TEMPLATE line needs to be changed as follows:
Before
#TEMPLATE(MYTEMPLATE,My wonderful template)
After
#TEMPLATE(MYTEMPLATE,My wonderful template),FAMILY(ABC,Clarion)
This allows MYTEMPLATE to be used in both the ABC and the Clarion families of template. Of course MYTEMPLATE, and My wonderful template would represent whatever names you have in your template.
Simple templates were copied over to a subdirectory under Clarion 4. The above changes were made and the templates registered.
I reopened the Clarion 4 application, removed the appropriate source procedures and embeds, and made new ones using the templates. After recompiling the application, I reran the tests. Still same results. Things were looking good.
One of the templates, A Simple Conversion Logging Template, creates a log file and writes entries to it. When I ran this through the converter, the source did not change at all. I thought it would have changed based upon the ABC file syntax, but it did not. I was particularly interested to see if this template would work when compiled. It did.
Having done the above steps, in minute detail, Ive resolved to test the next set of templates by adding the family, registering the set, and then testing them. When I find templates which do not convert, Ill repeat the detail steps listed above.
Converting simple templates to be used in the ABC chain will frequently be a simple, relatively painless process. Care should be taken to test that each template works.
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: $184
(includes all back issues since '99)
Renewals from $134
Two years: $274
Renewals from $224