Alpha Anywhere supports two similar capabilities:
Calculated Fields - where Alpha Anywhere uses a field rule to calculate the value of a table field
Calculated Variables - which you may place on a layout or use in computations
If you define a calculated field for a table, you can use it in any layout or operation defined for that table.
See also Calculated Fields.
In the Control Panel select the table and click Table > Edit Field Rules.
On the Field Types tab in the In the Extended field types group, click the Calculated radio button.
Optionally, change the Default descriptive name for this calculated field.
Optionally, change the Field description.
Enter the expression that computes the field value in the Calculated field expression field. The expression must return the same data type as the table field. Click to use the Expression Builder to help you define the expression.
A calculated field rule defines how Alpha Anywhere will calculate the value of a field in your table. You can then place this field on a layout, just as you would place any other field. The following procedure shows how the Extension field was calculated for the invoice_items table of the AlphaSports database.
Display the Tables/Sets tab of the Control Panel.
Select the "invoice_items" table and click Design > Field Rules.
Select the "invoice_items->Extension" field from the list box.
Display the Field Types tab.
Select the Calculated radio button.
Click the 'x-y' icon in the Calculated field expression control to display the Expression Builder.
Double click Field Name in the upper left corner of the dialog. Select "Price" and click Insert.
Place a multiplication symbol after "Price", so the expression is "Price*".
Double click Field Name in the upper left corner of the dialog. Select "Quantity" and click Insert, so the expression is "Price*Quantity".
Click OK to return to the Field Rules Editor.
Click Save OK > Close.
The following script forces all calculated fields in a table to be recalculated.
dim tbl as P tbl = table.open("yourtablename") while .not. tbl.fetch_eof() tbl.change_begin() tbl.change_end(.t.) tbl.fetch_next() end while tbl.close()