2. Embedded SQL for C : C Variables and Data Types : Variable and Type Declarations : How to Declare External Compiled Forms
 
Share this page                  
How to Declare External Compiled Forms
You can precompile your forms in the Visual-Forms Editor (VIFRED). By doing so, you save 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 the C language. The following system specific section contains the remaining information you will need to declare your forms.
Windows Forms
VIFRED prompts you for the name of the file with the description. After creating the file, you can use the following cl command to compile it into linkable object code:
cl -c filename
The C compiler usually returns warning messages during this operation. You can suppress these, if you wish, with the -w flag on the cl command line. This command results in an object file that contains 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 declare it in an embedded SQL declaration section, with the following syntax:
extern int *formname;
Syntax Notes:
The formname is the actual name of the form. VIFRED gives this name to the address of the external object. The formname is also used as the title of the form in other embedded SQL/FORMS statements.
The extern storage class associates the object with the external form definition.
Although you declare formname as a pointer, you should not precede it with an asterisk when using it in the addform statement.
The example below shows a typical form declaration and illustrates the difference between using the form's object definition and the form's name.
Example: Form declaration
exec sql begin declare section;
         extern int *empform;
         ...
exec sql end declare section;
         ...
exec frs addform :empform; /* the global object */
exec frs display empform;  /* the name of the form */
         ...
UNIX Forms
VIFRED prompts you for the name of the file with the description. After creating the file, you can use the following cc command to compile it into linkable object code:
cc -c filename
The C compiler usually returns warning messages during this operation. You can suppress these, if you wish, with the -w flag on the cc command line. This command results in an object file that contains 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 declare it in an embedded SQL declaration section, with the following syntax:
extern int *formname;
Syntax Notes:
The formname is the actual name of the form. VIFRED gives this name to the address of the external object. The formname is also used as the title of the form in other embedded SQL/FORMS statements.
The extern storage class associates the object with the external form definition.
Although you declare formname as a pointer, you should not precede it with an asterisk when using it in the addform statement.
The example below shows a typical form declaration and illustrates the difference between using the form's object definition and the form's name.
Example: Form declaration
exec sql begin declare section;
         extern int *empform;
         ...
exec sql end declare section;
         ...
exec frs addform :empform; /* the global object */
exec frs display empform; /* The name of the form */
         ...
VMS Forms
After the file is created, you can use the following command to assemble it into a linkable object module.
macro filename
This command produces an object file that contains 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 declare it in an embedded SQL declaration section, with the following syntax:
globalref int *formname;
Syntax Notes:
The formname is the actual name of the form. VIFRED gives this name to the address of the external object. The formname is also used as the title of the form in other embedded SQL/FORMS statements.
The globalref storage class associates the object with the external form definition.
Although you declare formname as a pointer, you should not precede it with an asterisk when using it in the addform statement.
The example below shows a typical form declaration and illustrates the difference between using the form's object definition and the form's name.
Example: Form declaration
exec sql begin declare section;
           globalref int *empform;
           ...
exec sql end declare section;
           ...
exec frs addform :empform; /* The global object */
exec frs display empform; /* The name of the form */
           ...