How to Declare External Compiled Forms—Windows and UNIX
You can precompile your forms in the Visual Forms Editor (VIFRED). This saves the time otherwise required at runtime to extract the form's definition from the database forms catalogs. When you compile a form in VIFRED, VIFRED creates a file in your directory describing the form in C. VIFRED prompts you for the name of the file with the C description. After the C file is created, you can use the following command to compile it into a linkable object module:
Windows:
cl -c
filename.c
UNIX:
cc -c
filename.c
This command produces an object file containing a global symbol with the same name as your form. Before the embedded SQL/FORMS statement addform can refer to this global object, you must use the following syntax to declare it in an embedded SQL declaration section:
01 formname [IS] EXTERNAL PIC S9(9) [USAGE [IS]] COMP-5.
Some platforms do not accept the above syntax
. If EXTERNAL data items cannot be referenced in your COBOL program, see
How to Include External Compiled Forms in the RTS (see page
How to Include External Compiled Forms in the RTS) in this chapter for an alternate procedure.
Syntax Notes:
• The formname is the actual name of the form. VIFRED gives this name to the global object. The formname is used to refer to the form in embedded SQL statements after the form has been made known to the FRS using the addform statement.
• The EXTERNAL clause causes the linker to associate the formname data item with the external formname symbol.
The following example shows a typical form declaration and illustrates the difference between using the form's global object definition and the form's name. However, currently, this example does not work on all Micro Focus platforms.
Example: Form declaration
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 empform IS EXTERNAL PIC S9(9) USAGE COMP-5.
* Other embedded SQL data declarations.
EXEC SQL END DECLARE SECTION END-EXEC.
PROCEDURE DIVISION.
* Program initialization.
* Making the form known to the FRS via the global
* form object.
EXEC FRS ADDFORM :empform END-EXEC.
* Displaying the form via the name of the form.
EXEC FRS DISPLAY empform END-EXEC.
* The program continues.
For information on linking your embedded SQL program with external compiled forms, see
How to Include External Compiled Forms in the RTS (see page
How to Include External Compiled Forms in the RTS) in this chapter.