Was this helpful?
Activate
Declares a section of program code within a display block; the code is executed when specified conditions occurred.
Examples--activate statement:
Example 1:
The following example creates a help menu item:
## activate menuitem "help"
##  {
##    help_frs (subject = "application",
##             file = "application.hlp")
##  }
Example 2:
In the following example, the code block executes when the user leaves the field specified by the variable fieldvar. If the code block detects no errors, it issues a resume next statement to advance the cursor to the next field. If an error is detected, the cursor does not advance.
##  activate field fieldvar
##  {
     if (no error) then
##        resume next
     end if
##  }
Example 3:
In the following example, the FRS validates the current field when the user selects the Next menu item or presses the function, control, or arrow key mapped to FRS key 3. The code in the block is executed only if the current field passes the validation.
## activate menuitem "next" (validate=1),
## frskey3 (validate=1)
## {
##   retrieve cursor cursor1 (vname, vage)
##   putform empform (ename = vname, age = vage)
## }
Example 4:
In the following example, the application displays help text if the user types a question mark (?) and moves the cursor out of the key field; otherwise, the users entry is validated.
##  activate field key
##  {
##   getform keyform (vkey = key)
     if (vkey = '?') then
##        help_frs (subject = "keys", file = "keys.hlp")
##        resume
    end if
    found = 0
##  retrieve (found = 1) where keys.key = vkey
    if (found = 1) then
##       resume next
    else
##       message "unknown key, please modify."
##       sleep 2
      end if
##    /* default action is to resume on same field */
##  }
Example 5:
This example disables the scrolldown operation for the employee table field.
## activate scrolldown employee
## {
## }
Example 6:
This example initiates a database validation check on the ename column before scrolling to the next row in the employee table field.
##  activate scrollup employee
##  {
##    getrow empform employee (vname = ename)
##         retrieve (rowcount = count(employee.empname
##              where employee.empname = vname))
      if (rowcount = 0) then
##         message "the employee entered does not exist"
##         sleep 2
      else
##         scroll empform employee up
    end if
##  }
Example 7:
In the following example, 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 was 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 statement is not executed.
## activate column employee sal
## {
     if (sal < 40000.00) then
##        resume next
     end if
##   message "reduce salary"
##   sleep 2
##   /* by default, the screen cursor resumes on the same
##   ** column. */
## }
## activate scrollup employee
## {
     program validation code
##   scroll empform employee up
## }
Example 8:
This example shows how the activate clause can be used to simplify data checking. The user cannot exit the field emp_name unless emp_name contains a valid name.
## activate field emp_name
## {
     check that emp_name contains a value
     if fail then
##        resume
     end if
##   resume next
## }
## activate menuitem "run" (activate = 1)
## {
     do processing based on value in field emp_name
## }
## activate frskey3 (activate = 1)
## {
     give raise to employee named in field emp_name
## }
Last modified date: 08/14/2024