You can specify a calculation that will set the value of a field on a form. For example, you could easily calculate a line item amount on an invoice from the price and number of units fields. Calculations may be performed across several forms. A calculated field could also update subtotal and total fields when, for example, a line item on an invoice is added, deleted or updated.
With formdef, you define each field on a data entry form with formdef's Field Description screen. See Chapter 5, Creating Formfiles for more information on creating forms. On the second Field Description Screen, there is a field labeled Copy/Calculate. This chapter describes the possible formulas (calculations) that may be used for calculating field values.
When form evaluates the Copy/Calculate formula of a field, form stores the result of the formula in that field. Normally, a Copy/Calculate field has Entry Allowed set to no. A Copy/Calculate field can be an Invisible field, allowing you to calculate values that are not displayed on the form. Form evaluates the Copy/Calculate formula in a field in the following situations
A new form is displayed (for example, by pressing the NEXTFORM key)
An existing form is cleared (for example, by pressing the ADD key)
A new record is displayed in an existing form (for example, by pressing the FIND key)
Another field changes and the Copy/Calculate formula depends on the other field value (for example, the amount field has the Copy/Calculate formula quantity * cost and you type a new value in the cost field)