Window scripts

To apply scripts to a window, open the layout for the window. Select the window by clicking somewhere outside of the window area. The window is selected when resize handles appear on the window’s perimeter. Display the Properties window and click the Script tab; the script types for the window will be displayed.

In the properties list, select the type of script to apply and click the lookup button. The Script Editor window will open. After you’ve saved the script, its name will appear next to the type in the properties list.

Window pre script   This script runs just as the window is opened. Typically, window pre scripts can be used to set default values in the window, or to disable buttons or specific fields before the window is displayed. Window pre scripts also run when the restart form or restart window statements are used.

For example, in windows that contain a Delete button, you may want to disable the button in the window pre script because the window contains nothing to delete when it opens.

disable field 'Delete Button';

When a record has been retrieved that the user can delete, the Delete button can be enabled by another script.

Window post script   This script runs just as the window is closed. For example, a window post script can be used to ascertain whether the entries in the window have been saved to a file when the user closes the window. If the information hasn’t been saved, the script could display a message asking the user whether he or she wants to save changes.

Window print script   This script runs when the window is active and the user chooses the Print menu item. Typically, the window print script uses the run report statement to run a report already created using the Report Writer.

For example, the following print script prints an invoice when the Invoice Entry window is active.

run report Invoice with restriction 'Invoice Number' of table Invoice_Master = 'Invoice Number';

Window activate script   This script runs each time the window becomes active, such as when it’s opened or brought to the front after the user has stopped working with another window. The window activate script runs after the window pre script.

The window activate script must be used cautiously. It should not contain any commands that create dialog windows (such as messages with the error or warning statements) because the application will become suspended in an endless loop.


ContextMenu script   This script runs when the user right-clicks on the window. It is used for context menus.


Documentation Feedback