The template code files contain template language statements and standard “target” language source code which the Application Generator places in your generated source code files. They also contain the prompts for the Application Generator which determine the standard customizations the developer can make to the generated code.
The programmer's response (or lack of) to the prompts “drives” the control statements that process the template language code, and produces the logic that generates the source code. The templates also contain control statements which instruct the Application Generator how to process the standard code. The function of a template is to generate the “target” language source code, customized per the programmer's response to the prompts and design of the window or report.
There are some lines of code from templates that are inserted directly into your generated source code. For example, if you accept a default Copy command menu item in your application window, the following code is inserted in your generated source exactly as it appears in the template file:
ITEM('&Copy'),USE(?Copy),STD(STD:Copy),MSG('Copy item to Windows clipboard')
Some of the standard code in the template is a mix of “target” (Clarion) language statements and template language statements. For example, when the contents of a template variable (symbol) needs to be inserted in the generated source code, the Application Generator expands the symbol to the value the application will use, as it generates the source code for the application. Within the template code, the percent sign (%) identifies a variable (symbol). In the example below, the Application Generator will fill in the field equate label for the control as it writes the source code file, substituting it for the %Control variable:
To support customizing the template starting point at design time, Clarion's template language provides prompt statements that generate the template's user interface, so that the Application Generator can query the developer for the information needed to customize the application. The basic interface consists of command buttons, check boxes, radio buttons, and entry controls placed on the Procedure Properties dialog. These statements can also create custom dialog boxes to gather input from the developer. While working with the Application Generator, therefore, some of the dialogs and other interface elements the developer sees are not part of the Application Generator, rather they are produced by the template.
For example, the following statement displays a file selection dialog from the application's data dictionary, then stores the programmer's choice for a data file in a variable (symbol) called %MyFile:
#PROMPT('Pick a file',FILE),%MyFile
It makes no difference what the programmer names the files and fields, nor what database driver is selected. The programmer picks them from a file selection dialog.
The template also contains control structures to instruct the Application Generator on how to generate the code(e.g., #IF, #LOOP, #CASE). These control statements work in the same manner as Clarion language control structures.