Was this helpful?
View Examples of Escape Code
This section provides examples of various types of escape code that you can use in developing a Vision application. You also can view additional examples on your terminal display while you are creating escape code in Vision.
To see examples of escape code while you are using Vision
1. Select Edit from the menu in the Application Flow Diagram or visual query display window for the current frame.
2. Select Escape Code from the list of options.
3. Select Help from the menu.
Vision displays information about escape code types.
4. Select SubTopics from the menu.
Vision displays a selection list of escape code types.
5. Select the escape code type for which you want to see examples.
Vision displays examples of this escape code, as well as any additional warnings or restrictions about using this type.
Alternatively, you can display the examples after you have selected a type and displayed the blank window for entering the actual escape code. To do this, select Help when Vision displays the window in which you enter your escape code, as described in the procedures below.
You also can use the SubTopics operation of the Help facility to display examples of standard 4GL statements if you need help with syntax while entering your escape code.
Escape Code Examples
The following are examples of escape code to perform various functions in an application.
Form-Start escape code to check the password that a user enters against a table of authorized users and their passwords:
pswd = prompt noecho 'Enter your password: '
with style = popup;

formname = select cnt = count(*)
from users
where user = dbmsinfo ('username')
and password = :pswd;

if (cnt = 0) then
message 'No authorization for this application'
with style = popup;
exit;
endif;
Form-Start escape code to retrieve data into local variables:
formname = select h_name= e.name,
h_status = e.status
from employees e
where e.empno = :empno;
Menu-Start escape code to verify that a particular field contains a value before calling the frame. This example shows using a resume statement to skip Vision-generated code:
if (last_name = '') then
callproc beep(); /* a 4gl procedure */
message 'You must enter a last name'
with style = popup;
resume;
endif;
Menu-End escape code to return a value based on what action the user takes on a frame. This example uses a built-in global variable called "IIretval" to communicate between frames:
if (IIretval = 2) then
/* user selected TopFrame in called frame */
elseif (IIretval = -1) then
/* an error occurred in called frame*/
else
/* called frame finished or user selected end */
endif;
Query-Start escape code to retrieve data into table fields on a form:
formname.tblfldname = select name = c.name,
balance = c.balance
from customers c
where c.custno = :custno;
Query-End escape code to check how many rows the user selected:
inquire_sql (rows = rowcount);
Append-Start escape code on an Update frame to increment the sequenced field "seq_key" in the "orders" Master table:
seq_key = callproc sequence_value
(table_name = 'orders',column_name = 'order_no',
increment = 1, start_value= 1);
commit work;
For more information on specifying sequenced fields, see Defining Append frames in Defining Frames with Visual Queries.
Form-Start escape code to pass a last name as a parameter to a Browse or Update frame. The child frame:
Has the Master table displayed as a table field
Has the Qualification Processing frame behavior disabled
The value is passed into a local variable (called "l_lname") on the child frame. The escape code then assigns the passed value into the table field for the Master table, where the value is used to qualify the query that determines the first record that a user sees.
/* form-start escape code for child frame */

insertrow iitf[0]: /*open a row in the table field*/

/* Assign passed-in value to newly-opened row. Then
use this value to qualify the query. */

if (l_lname != '') then /* A value was passed */
iitf[1].lname = l_lname;
endif;
After-Field-Exit escape code to update a column in the database with the result of the date_trunc function. If the date is entered incorrectly, the function returns NULL. To ensure that the data in the database is not overwritten with a NULL value, include error checking in your escape code.
mo_date := date_trunc( 'day', mo_date );
inquire_forms frs ( IIerrorno = errorno );
if IIerrorno != 0 then
message 'Invalid date format entered - Please '
+ 'REENTER' with style = popup;
resume; /* Breakout of current display loop and go
back to the field w/ bad data */
endif;
Last modified date: 11/28/2023