Basic Structure of a Forms-based Program
The following example presents a simple forms-based program. This example illustrates the fundamental forms statements and their relative positions in the program.
exec sql include sqlca;
exec sql begin declare section;
namevar character_string(20);
salvar float;
exec sql end declare section;
exec sql whenever sqlerror stop;
exec sql connect personnel;
exec frs forms;
exec frs forminit empform;
exec frs display empform;
exec frs initialize (ename = :namevar, sal = :salvar);
exec frs activate menuitem 'Help';
exec frs begin;
program code;
exec frs end;
exec frs activate menuitem 'Add';
exec frs begin;
program code;
exec frs end;
exec frs activate menuitem 'End';
exec frs begin;
exec frs enddisplay;
exec frs end;
exec frs finalize;
exec frs endforms;
exec sql disconnect;
The section of code beginning with the statement display and ending with finalize constitutes the display block for the form empform. The statement in the display block specifies the operations available with the form. In the preceding example, the activate menuitem statements create a menu line that looks like this:
Help Add End
You can also display forms that have no associated operations. Under certain circumstances, a program can display a form without even being connected to a database. It is not a requirement of the FRS that a forms application needs a database connection. Generally, however, forms applications include database operations and so require connection to a database.
Last modified date: 08/28/2024