17. Forms Statements : activate Statement--Activate a Section of Code : The Column Condition
 
Share this page                  
The Column Condition
For the column condition you can specify two options:
Entry activation
Specifies that the code is executed when the user moves the cursor into the specified table field column. Entry activations are also executed when the resume column places the cursor in a column.
Exit activation
Specifies that the code is executed when the user moves the cursor out of the specified table field column. (Exit activations do not occur if the table field is displayed in read mode.)
To specify an entry activation, use the following syntax:
activate before column tablename columnname|all
begin
    program code;
end
To specify an exit activation, use the following syntax:
activate [after] column tablename columnname|all
begin
    program code;
end
By default, the activation occurs only when the user moves the cursor into or out of a column (depending on which variation you chose). When you specify an exit activation, moving the cursor up or down a row in the table field display also constitutes an exit and executes the program code.
If you want to execute the code as a result of some other user action, for example, whenever the user presses a function key or selects a menu item while the cursor resides in the specified column, use the set_frs statement or an explicit activate clause. The set_frs Statement--Set FRS Features can define global column activations. See The Menuitem Condition and The Frskey Condition for a description of how to use the activate clause.
You can specify both tablename and columnname as quoted or unquoted character strings or as program variables. If you use the key word all instead of a specific column name, then the program code is executed whenever any column in the table field is entered (or exited, depending on what you specified).
By default, after an exit activation, the FRS positions the cursor back on the same column. For this reason be sure to include a resume statement that moves the cursor to another field or column when the operation is complete.
The resume next statement is very important if the column activation is the result of a menuitem or frskey selection. Without this statement, the block of code associated with the selected menuitem or frskey condition is not executed. It appears as if the menuitem or frskey condition was never selected.
Because it is possible for the user to initiate a scroll upon leaving a column (for instance, by attempting to move the cursor down a line when it is already on the last row of the table field), it is important to understand what happens when the display block includes activate column and activate scroll statements, both of which are affected by the user's action. In such a case, the activate column statement has the higher priority and is executed first. If execution of the activate column terminates with a resume next statement, the program next processes the activate scroll statement.