9. Overview of the Template Files

Genero Studio video scripts

Related video: 9. Overview of the Template Files

In this video, you will see the files that are used for code generation.  You may find it helpful to modify the template from which your code is generated. For example you may find that instead of adding POINT or BLOCK code repeatedly for each application, you want to create a new template that includes your customized code.

 

Modifying the default templates requires a basic knowledge of Genero Business Development Language (BDL) and the TCL language or another template language. Genero Application Generator uses the TCL Generator by default, but it can be replaced by a generator of your choice such as XSLT, perl, python, and so on, or BDL.

 

You should not change the default templates. Instead, create your own template directory:

  1. Copy the entire content of the /gst/bin/src/ag/tpl/dbapp directory to a new folder. The new template directory could be a common one on the server or it could be part of the entire versioned project.
  2. From Genero Studio, select Tools >> Preferences, Application Generator. Right-click on the Templates List and choose Add Template.. Provide a name and path to the new directory and an optional description of the template.
  3. To use the new template, select the new template set in the list and select the icon in the integrated toolbar to set it to the new default template.

Now you can customize the files that you copied into the new directory. Keep the same filenames as the default template set. All your programs will be generated with these files; the default files will be ignored.

Note: You may need to update the environment variables such as FGLLDPATH, FGLRESOURCEPATH to use the custom templates.

 

In the template directory, you’ll see a file set like this. Each file is responsible for a part of the code generation.

The main directory holds the .tcl files as well as a few associated files and the resources directory holds the templates for files like the toolbar and topmenu, as well as the sources of the library files that handle some of the generic tasks (such as the .4gl files used to create libdbapp.42x.)

 

Let’s start with the tcl files.

The common.tcl file provides common procedures used by other TCL templates.

data.tcl is a library of functions used in other TCL scripts like uidata.tcl, reportdata.tcl

The defines.tcl provides global defines used by other TCL templates.  

The error.tcl file provides procedures used by other TCL templates to handle errors and warnings.

The lookup.tcl generates the lookup DOM.

The main.tcl generates the .4gl associated to a .4prg.

The report.tcl generates the .4gl report section associated to a .4rd file.

The reportdata.tcl generates the .4gl data management section associated to a .4rd.

The ui.tcl generates the .4gl user Interface section associated to a form  .4fdm file.

The uidata.tcl generates the .4gl data management section associated to a .4fdm.

The additional files are settings.agconf which is an xml file used to define new items and properties in the BA Diagram.  The creatables.conf file is an xml file used to define new actions for file creation (in the BA diagram context menu or File >> New), and to add new template files to use instead of starting with empty files. The file-types.xml file is an xml file used to define new files types to be available in the template. Last, dbapp.4pw is the project template preconfigured with dependency to libgre.42x already set