Examples of Altering Template Files
To alter the template files, use one of the following:
• Change the text of error messages or prompts. Use your text editor to change the wording of error messages in the template files.
• Add a menu item for a commonly used utility. For example, to add a 'Mail' menu item to every menu frame, include code similar to the following in ntmenu.tf, just before the 'End' menu item:
'Mail' (Validate = 0, Activate = 0, Explanation =
'Access system mail') =
BEGIN
/*4GL code to call the system mail utility */
END
This menu item appears in the top menu only if you can use the substitution variable $default_start_frame:
## IF $default_start_frame THEN
'Mail' (Validate = 0, Activate = 0, Explanation =
'Access system mail') =
BEGIN
/*4GL code to call the system mail utility */
END
## ENDIF
• Add user prompts at the end of transactions. For example, you can add a prompt following all Deletes in the Master table field frames which prompts for input before clearing the window and returning from the submenu to the main menu. This reminds the user what the last transaction was before the window is cleared. In this example, code was added to inmtdlmn.tf (Master in table field Delete menuitem), just before the ENDLOOP which exits the UNLOADTABLE loop:
IIchar1 = prompt 'You have deleted ' +
varchar(:IIrowcount)
+ ' rows. Hit RETURN when you are ready to'
+ ' continue:';
ENDLOOP; /*exit submenu */
• Use an environment variable to control which code is generated:
## IFDEF $$VERBOSE_MODE
/* 4GL code to run in verbose mode */
## ENDIF
The generated code can be altered by setting or unsetting the environment variable VERBOSE_MODE at the operating system level.
• Another way of controlling which code is generated is to use substitution variables, for example, your template files can contain code which is dependent on a substitution variable which you have defined:
## IF ('$_mode' = 'verbose') THEN
/* 4gl code to run in verbose mode */
## ELSE IF ('$_mode' = 'expert') THEN
/* 4gl code to run in expert mode */
## ELSE
/* 4gl code to run in standard mode */
## ENDIF
Then the code can be generated in three different ways, depending on how you define this environment variable (intopdef.tf is a good place to do this):
## DEFINE $_mode 'verbose' could be 'expert' or some other value
Last modified date: 08/14/2024