Was this helpful?
How Writing Escape Code Works
Vision generates the 4GL code for Menu, Append, Browse and Update frames based on the Application Flow Diagram and visual query specifications. You can also add functions to these frames not provided by the Vision-generated code by writing 4GL statements called escape code. Vision generates the basic code for your application and includes escape code to perform additional functions that are not part of the visual query.
For example, you can write escape code to:
Display messages or prompts when the user calls a frame, enters a field, or selects a menu item
Keep track of how many records are retrieved, updated, or appended on a frame
Set "if-then" conditions for calling frames or taking other actions
Assign initial values to global or local variables
You can use any 4GL statements in your escape code, subject to the restrictions discussed below. Your escape code must follow the standard 4GL syntax, with a semicolon (;) at the end of each statement.
The 4GL reference part of this guide discusses how to write 4GL code and provides a complete description of each statement and its syntax.
When you write escape code for a frame, you must specify its type, as determined by the point at which the escape code is activated when Vision runs the frame. For example, Form-Start escape code is activated before a form is displayed.
In addition to the escape code itself, Vision also generates a comment in the source code file so that you can locate the escape code. These comments are especially helpful when you are trying to correct errors in the code you wrote.
As a simple example of escape code, you can have Vision generate a message when a user starts the application. To do this, include a 4GL message statement on the top frame.
The escape code looks like this in the source code file:
/*# BEGIN Form-Start */
message 'Welcome to the Order Entry System';
/*# END Form-Start */
When a user starts the application, the message appears before the form is displayed for the top Menu frame.
Additional examples of escape code are given later in this section.
Last modified date: 04/03/2024