9. Modifying Vision Code : Modifying the Template Files : Using Substitution Variables in Template Files
 
Share this page                  
Using Substitution Variables in Template Files
Vision template files use global variables called substitution variables. These variables have the form $variable.
When Vision generates the code for a frame, actual values are substituted for $variables. Variable substitution takes place everywhere, even inside quoted strings and comments.
When substitution variables are used in executable "template language" statements—such as the ## generate statement—that are translated into 4GL statements, the values are substituted before the statement is evaluated.
Substitution variables can be system-defined or user-defined:
System-defined substitution variables represent the information about a frame that you specified with the Visual Query Editor or other Vision components. For example, the variable $master_table_name represents the name of the master table you specified when you created the frame.
You cannot directly change the value of a system-defined substitution variable in a template file, but you can use them in your own 4GL or template language code in template files.
User-defined substitution variables are variables that you create with the ## define statement. Assign a value to the substitution variable when you create it and include the value in 4GL or template language code. Use the ## undef statement to undefine a user-defined substitution variable.
User-defined and system-defined substitution variables are described in detail in Template Files Reference. The tables in the appendix list the substitution variables recognized by the code generator.
Use the name of a logical or environment variable as the value of a substitution variable, as discussed in Using Logicals or Environment Variables in Template Files.