Using the Set_forms Statement
The set_forms statement allows you to control many of the features of the FRS while the application is running with the statement:
set_forms
Most set_forms statement variants have a corresponding inquire_forms variant. This allows you to both set and query on the FRS features while the application is running. For example, use set_forms to turn on the blinking feature in a field to remind a user to enter a value, as in this example:
set_forms field dataform
(blink (name) = 1);
Use another set_forms statement to turn blinking off, after the user enters the value:
set_forms field dataform
(blink (name) = 0);
Tracking Changes to Form Fields and Rows
Changes made for each form, field or row are tracked with a change bit or change variable. Change bits are maintained for each simple field on a form and for each intersection of row and column in a table field and data set. The change bits are:
• Cleared (set to 0); used in the following cases:
• At the start of a display loop
• When the application places a new value into the field
• When the form, field, or row is set or cleared by the program
• When another frame or procedure to which the field or column has been passed by reference returns
• Set (set to 1), used whenever data is entered or re-entered by the user
An application can perform its own validations on values in fields, forms, and rows by checking the change bit. This reduces the number of times the value itself needs to be validated.
To set or clear the change bit, use the set_forms form, set_forms field, or set_forms row statements. The following example clears the change bit for salary on the addemp form:
set_forms field addemp (change(salary) = 0);
The following example clears the change bit for the "start_date" column in the second row of the "emp_hist" table field on the "addemp" form:
set_forms row addemp emp_hist 2
(change (start_date) = 0)
To inquire about the change bit, use the
Inquire_forms Field statements. For example:
inquire_forms field addemp
(integer_variable = change(salary));
This statement inquires about changes to the salary field on the Addemp form. The integer_variable is set to 1 if salary is changed. Change is a keyword in the statement.
The following example uses the change bit when a table-field column is involved. It checks the "start_date" column for the current row in the "emp_hist" table field. This approach can also be used in an unloadtable loop.
inquire_forms row addemp emp_hist
(integer_variable = change(start_date));
To track changes made to the form as a whole, use the inquire_forms form statement with the change FRS constant. For example:
'Save' =
begin /* Save changes to fields */
set_forms form (change = 0);
end
'End' =
begin /* Call procedure 'oktoend' */
if oktoend() = 1 then
return;
endif;
end
/* Code for procedure 'oktoend' follows: */
procedure oktoend(anychange = integer,
ans = varchar(1)) =
begin
inquire_forms form(anychange = change);
if anychange = 1 then
ans := prompt 'Changes were not saved.' +
'Would you like to end anyway?'
with style = popup;
if lowercase(left(ans,1)) = 'y' then
return 1;
else
return 0; /* continue working */
endif;
else
return 1;
endif;
end
After performing a save, the example uses set_forms to clear the change status to 0. This status is set to 1 whenever the user types over the data displayed on the form. Before exiting a form, an application can check for unsaved changes.
Last modified date: 08/14/2024