6.8 Formulas

The following sections describe the formulas that you can enter into the Copy/Calculate and Edit/Match fields on the Field Description screen.

A formula is a sequence of one or more statements separated by a new line or ;. A formula calculates a value that becomes the new value of the field (for Copy/Calculate formulas), or is an error message (for Edit/Match formulas). Each statement calculates a value; the value of the formula is the value of the last statement evaluated.

For example, the formula

quantity * price

has one statement, an expression, that calculates the quantity times the price.

The formula

if cost >= 100.00

"cost must be less than $100.00"

else

""

endif

returns either the string cost must be less than $100.00 (if the cost field is greater than or equal to 100.00), or the empty string. Since the else part returns an empty string, you can leave it out. The following formula has the same result

if cost >= 100.00

"cost must be less than $100.00"

endif

This example could also be written as

if cost >= 100.00; "cost must be less than $100.00" endif