Programming Guide



sm_calc

Executes a math expression

int sm_calc(int field_number, int occurrence, char *expression);

field_number
The field to use for relative field references, for backward compatibility only. If expression references fields according to current conventions, supply 0.

occurrence
The occurrence in field_number to use for relative field references, for backward compatibility only. If expression references fields according to current conventions, supply 0.

expression
A math expression. Refer to "Performing Calculations and Validating Numbers" in Using the Editors for information on creating math expressions.

Returns

Description

sm_calc lets you execute a math expression. Use this function to perform mathematical operations that use the contents of one or more fields and then insert the result into a field.

If, in the event of a math error, you want the cursor to move a specific field, specify that field with field_number. If the field is an array and occurrence is offscreen, Panther scrolls that occurrence into view.

Example

/* Compute payment due date. */

sm_calc(0, 0, "paymentduedate = @date(shipdate) + 30");