Use the RECALC command in an entry/exit procedure (EEP) to recalculate expressions in a form.
Options
TABLES
Finds, recalculates, and redraws the lower-level tables to reflect the actions of the entry/exit procedure (EEP). The recalculations will be performed only for the active table (the table of the currently focused control).
VARIABLES
Recalculates all variables for the current table.
VARIABLES varlist
Recalculates a list of one or more variables. Use this option at the end of a set of procedures to recalculate variables.
About the RECALC Command
Without using the RECALC Command in EEPs-A recalculation takes place when you move to the field following the field that triggered the EEP. R:BASE automatically redisplays the value in a form field (variable) that calls the EEP. Redisplaying the value in a form field ensures that the field always contains the correct value.
To automatically redisplay a field, the following statements must be true:
•The EEP must be started from the field you want redisplayed.
•The field you want redisplayed must be a variable.
•The EEP loads a new value into a variable that is the same as the variable that started the EEP.
If you want to load the value into a column, create a form expression that equates the variable and the column, for example, colname=.varname.
Using the RECALC Command in EEPs-Use RECALC to ensure that expressions based on variables modified by an EEP are always current. RECALC only updates expressions when the following conditions apply:
•The field containing the EEP is a variable.
•The EEP changes the value of the variable.
•The EEP runs the RECALC command before returning to the form.
•At least one form expression has the variable to the right of the equal sign, which signifies a dependent expression.
When you use the RECALC command without any options, RECALC redisplays only the variable in the field that started the EEP, and recalculates only expressions using that variable. Use the VARIABLES option to force redisplay of all variables placed on the form and recalculation of all table expressions. Use the TABLES option to force recalculation of expressions in the other tables used in a multi-table form. The TABLES option recalculates lower tables only, not the current table.
Examples
Example 01:
If you have an EEP in a form that calculates a value for a variable that you want to load into a column, follow the procedure below:
To calculate a value for a variable to load into a column:
1. | Place the variable on the form. |
2. | Include the EEP in the field settings for the variable. |
3. | Create an expression that equates the column to the variable so that the variable is loaded into the column. |
For example: colname1 = (.varname1) |
4. | Include RECALC or RECALC VARIABLES in the EEP. |
For example, a procedure that calculates the sum from a column could be: |
SELECT SUM colname2 INTO varname1 FROM tblname WHERE + |
colname3 = .varname2 |
RECALC VARIABLES |
RETURN |
Example 02:
--Recalculates the values for the variables vTargetPrice, vShippedQuantity, and vDiscountedRate
RECALC VARIABLES vTargetPrice, vShippedQuantity, vDiscountedRate
Example 03:
--Recalculates data for lower-level tables
RECALC TABLES