Table Field Activation Operations
There are two types of activation operations that can be specified only for table fields:
scroll activations and
column activations. These are described in the following sections. For a discussion of activation operations in general, see
Activation Operations.
Scroll Activations
To define operations that are activated when the user attempts to scroll up or down the table field, use the activate scrollup and activate scrolldown statements. If these statements are included in a display block, automatic scrolling no longer occurs. Instead, when the user attempts to scroll in the specified direction, control passes to the activate block and the statements in that block are executed. If the block does not contain any statement that scrolls the table field, no scroll occurs. Therefore, unless your intent is to disable scrolling, you must include in such operations the variant of the scroll statement that functions like an automatic FRS scroll.
Situations in which you might want to activate an operation on a scroll attempt are extremely limited when dealing with table fields with attached data sets; ordinarily, the automatic FRS scrolls provide sufficient scrolling capability. One use for scroll activation might be to force a complex validation check (for instance, a check on a database table) on a row before it is scrolled. As mentioned above, you can also use scroll activations to disable scrolling. For instance, if you want to prevent the user from scrolling backward through the table field, you can include an activate scrolldown section with an empty statement block:
exec frs activate scrolldown employee;
exec frs begin;
exec frs end;
An activate scrolldown is used here because scrolling backward through the form causes the rows above the table field to be moved down into the display.
An operation equivalent to automatic FRS scrolling can be specified as follows:
exec frs activate scrollup employee;
exec frs begin;
exec frs message 'Scrolling up';
exec frs sleep 1;
exec frs scroll empform employee up;
exec frs end;
Details on scroll activation can be found in the activate and scroll statement descriptions in
Forms Statements.
activate Statement--Activate on a Column
There are two types of column activations, entry and exit. If an entry activation is defined for a column, then activation occurs when the user moves the cursor into that column. Similarly, if an exit activation is defined for a column, then the activation occurs when the user moves the cursor out of a column.
The syntax for entry activation is as follows:
activate before column tablefieldname columnname|all;
begin;
program code;
end;
The syntax for exit activation is as follows:
activate [after] column tablefieldname columnname|all;
begin;
program code;
end;
If you specify the key word all in either statement, then the specified activation occurs on all columns in the table field.
A column activation can occur when the user moves the cursor into a column or out of the column, or both, if you supply two activate column blocks, one for each type of action.
A number of cursor movements can cause column activations: moving the cursor to the next or previous column, or moving the cursor up or down a row in the table field. Therefore, the FRS must remember what action caused the activate column statement, so that the action can be completed when the section of code has been executed. By using a resume next statement at the end of the code section, you can specify that the action that caused the activate column operation is to be completed after the operation finishes. In the following program fragment, the resume next, specifies that execution is to continue if the column contains good data; if the program detects bad data, it displays an error message and places the cursor in the column in which the bad data was entered by issuing the resume statement.
/* Assume previous declarations, plus ... */
exec sql begin declare section;
rowcount integer;
exec sql end declare section;
...
exec frs activate column employee ename;
exec frs begin;
/*
** Get the name of the user and verify that it is
** unique in the Employee table. If it is, continue
** movement of cursor out of the Ename column; if it
** is not, remain in the same column.
*/
exec frs getrow empform employee (:ename = ename);
exec sql select count(*)
into :rowcount
from employee
where employee.ename = :ename;
if (rowcount = 0) then
/* The name is unique, so continue. */
exec frs resume next;
else
/* The name is not unique,
** so remain on column. */
exec frs message 'Employee name must be unique';
exec frs sleep 2;
exec frs resume;
end if;
exec frs end;
...
A program can position the cursor to a particular column in the current row using the resume column statement:
resume column tablename columnname;