Using Logicals or Environment Variables in Template Files
The Vision code generator treats the string $$logical in a template file as the name of a logical or environment variable. If logical has been defined, Vision substitutes its value into the generated 4GL code wherever the $$logical string appears in the template.
For example, if you have defined II_TFDIR to a specific directory, the code generator substitutes that directory wherever the string $$II_TFDIR appears in the template file.
Logicals in 4GL Statements
If $$logical appears in a 4GL statement (that is, a non-executable statement) in a template file, its definition is written directly into the generated 4GL source code.
The string $$logical is written directly into the generated code as it appears in the template file if:
• The logical or environment variable has not been defined
• The code generator cannot locate the value of logical
Include any number of logicals in 4GL statements in template files. However, logicals cannot be nested; that is, the definition of a logical is not checked to see it if refers to another logical. (An exception to this restriction is when the operating system performs the translation.)
Logicals in Executable Statements
If $$logical appears in an executable template language statement (one that begins with "##"), the code generator translates the logical before it evaluates the statement. If the logical has not been defined, an empty string is substituted for $$logical.
Include no more than one logical in each ## statement. If more than one appears, the code generator translates all the logicals to the definition of the last one in the statement.
Verifying That a Logical Is Defined
The most common way to include a logical is to use it within an ##ifdef/else/endif block. The code within the block is included in the generated source file only if the logical exists and has been defined to a value other than the empty string.
For example:
##IFDEF $$logical
/* put this code in generated 4GL file if $$logical exists*/
##ELSE
/* put this code in generated 4GL file if $$logical does not exist */
##ENDIF
Do not use $$logical variables in ##if-endif statements.
Size Limitations for Logical Definitions
The definition of a $$logical in a template file must be no longer than 256 characters. (This limit is longer on some operating systems.) If the definition is longer than the allowed length, then only the allowed number of characters is included in the generated code.
Last modified date: 08/28/2024