Was this helpful?
addform Statement--Declare a Pre-compiled Form
This statement declares a pre-compiled form to the FRS.
Syntax
addform :formname
Description
The addform statement declares a pre-compiled form to the FRS. Declaring a form makes its definition known to the FRS. A pre-compiled form is a form that has been compiled into object code. You cannot use the addform statement to declare a form that resides in a database. For these forms, you must use the forminit statement instead. All forms must be declared with either addform or forminit before you can use them in the application. (It is only necessary to declare a form once in an application, regardless of how many times it is displayed.)
Pre-compiling a form eliminates the need to access the forms catalogs in the database for the form's definition. This substantially reduces the time required to start a forms application and also allows you to use the FRS on the form without necessarily being connected to any database. However, because the form is pre-compiled, any changes made to the form through VIFRED necessitate its recompiling and relinking into the application.
Before you can issue this statement, you must:
1. Create and compile the form in VIFRED.
2. Compile the compiled form into object code.
3. Link the form object code into the program.
4. Declare a program variable for the address of the form's definition.
See your host language companion guide and Character-based Querying and Reporting Tools User Guide for complete information about these procedures.
The formname is the name given the form in VIFRED. Some implementations require that formname be a variable or string literal specifying a file name. See your host language companion guide for details.
You must include the colon in front of the formname because addform references the variable that contains the form's address, not the form name itself. (This is the only time in the program that formname is preceded by a colon.)
If the specified form has a VIFRED table look up validation defined for it of the type field in table.column, then a run time query against the database is issued when the addform executes. That query reads all the values in table.column into memory. If no transaction is open when this occurs, then addform issues a commit afterwards, which releases all its locks on the table from which the validation data is read. If a transaction is open, then addform does not commit afterwards. The application continues to hold the shared locks until the next commit or end transaction statement. These locks allow other users to select from the tables but prevent anyone from changing them. Because of this, applications must, whenever possible, commit open transactions before issuing the addform statement.
Examples--addform statement:
Example 1:
Declare the form empform.
exec sql begin declare section;
    empform external integer;
exec sql end declare section;
    ...
 exec frs addform :empform;
Example 2:
Inside a local procedure, which is called more than once, you control the reissuing of the addform statement.
exec sql begin declare section;
    empform external integer;
    added integer; /* statically initialized to 0 */
exec sql end declare section;
...
 if (added = 0) then
    exec frs addform :empform;
    added = 1;
end if;
Last modified date: 08/14/2024