Was this helpful?
The Timeout Condition
The timeout condition has the following syntax:
activate timeout
begin
    program code
end
This condition is activated whenever the display loop times out. A display loop times out when the user fails to perform some keyboard action, such as moving the cursor, entering data, or making a menu choice, before a specified time period expires. (For a general discussion of the timeout feature and to the set_frs statement description for information about setting the timeout period, see Part 4: Embedded Forms Programming.)
When an activate timeout block that is part of a display or display submenu loop completes or executes a resume statement, the cursor returns to the current field or column. If it cannot return to the field or column, it returns to the menu line.
If the block is part of a submenu statement, execution of a resume or completion of the block results in completion of the submenu statement.
Examples--activate statement:
Example 1:
Create a Help menu item.
exec frs activate menuitem 'Help';
exec frs begin;
    exec frs help_frs (subject = 'Application', 
      file = 'application.hlp');
exec frs end;
Example 2:
Cause execution of an operation when the user leaves the field specified by the variable fieldvar. If there were no errors, then continue with the user's movement out of the field. Otherwise, the default operation—resuming on the same field—is executed.
exec frs activate field :fieldvar;
exec frs begin;
    if (no error) then
         exec frs resume next;
    end if;
exec frs end;
Example 3:
Cause execution of an operation when the user either selects the Next menu item or presses the function/control key mapped to FRS Key 3; validate in either case.
exec frs activate menuitem 'Next' (validate=1),
    frskey3 (validate=1);
exec frs begin;
    exec frs fetch cursor1
         into :ename, :age;
    exec frs putform empform
         (ename = :ename, age = :age);
exec frs end;
Example 4:
When the user moves out of field key, provide help if the value of the field is ?. Otherwise, validate the value.
exec frs activate field key;
 exec frs begin;
    exec frs getform keyform (:key = key);
    if (key = '?') then
        exec frs help_frs
           (subject = 'Keys', file = 'keys.hlp');
        exec frs resume;
    end if;
    found = 0;
    exec sql select 1 
        into :found
        from keys
        where key = :key;
    if (found = 1) then
        exec frs resume next;
    else
        exec frs message 
           'Unknown key, please modify.';
        exec frs sleep 2;
    end if;
    /* Default action is to resume on same field */
exec frs end;
Example 5:
Prevent the user from scrolling backward through the employee table field, by disabling the scrolldown operation.
exec frs activate scrolldown employee;
 exec frs begin;
exec frs end;
Example 6:
Initiate a database validation check on the ename column before scrolling to the next row in the employee table field.
exec frs activate scrollup employee;
 exec frs begin;
    exec frs getrow empform employee
        (:ename = ename);
    exec sql select count(*)
        into :rowcount
        from employee
        where employee.ename = :ename;
    if rowcount = 0 then
        exec frs message 
            'The employee entered does not exist';
        exec frs sleep 2;
    else
        exec frs scroll empform employee up;
    end if;
exec frs end;
Example 7:
When the user attempts to move the cursor out of the sal column, the activate column block is executed. If the value in sal is valid, the program continues with whatever action initiated the activate column block. If the user had been attempting to move the cursor down a row while on the last displayed row of the table field, the activate scrollup block is executed at this time. If, however, the value in sal is not valid, the cursor resumes on the original column and row, and the activate scrollup block is not executed.
exec frs activate column employee sal;
 exec frs begin;
    if sal < 40000.00 then
        exec frs resume next;
    end if;
    exec frs message 'Reduce salary';
    exec frs sleep 2;
    /* By default, the screen cursor resumes
    ** on the same column. */
exec frs end;
 exec frs activate scrollup employee;
exec frs begin;
    program validation code;
    exec frs scroll empform employee up;
exec frs end;
Example 8:
This example shows how the activate clause can be used to simplify data checking. A given form has only one field, the emp_name field, which must contain a valid name before the user is allowed to leave the field or select either menu item, run or frskey3.
exec frs activate field emp_name;
 exec frs begin;
    check that emp_name contains a value;
    if fail then
         exec frs resume;
    end if;
    exec frs resume next;
exec frs end;
 exec frs activate menuitem 'Run' (activate = 1);
exec frs begin;
    do processing based on value in field emp_name;
 exec frs end;
 exec frs activate frskey3 (activate = 1);
exec frs begin;
    give raise to employee named in field emp_name;
 exec frs end;
Last modified date: 08/28/2024