Defining a Compute Field

A compute field is one of the five types of derived fields you can define. It calculates a value using existing fields and values. Use this procedure to define a compute field.

For more information on compute fields, see Compute Fields.

To define a compute field

  1. On the File Definition form, move the cursor to the blank line below the last defined field in the Field Name column. (If you do not want the field added at the end of the list, highlight the field just below where you want a new field inserted and press Insert (F8).)
  2. Type a field name and press Tab.
  3. In the Element field, type an element name and press Tab.

    The Select an Element Type for Element subform appears.

  4. Select the Compute Field derived type.
  5. In the Define Compute Statement subform, type a compute statement.

    You can use up to 10 operands (fields and values) and 9 operators in the compute statement. The valid operators are add (+), subtract (-), multiply (*), divide (/), and exponentiation (^). Use parentheses to define precedence. The default precedence of operators is parentheses, exponentiation, multiplication, division, addition, and subtraction.

    The following table describes options you have for compute statements.

    Note: You cannot use an array field in a compute statement, but you can use an array value field.
    Option Procedure
    Use a field in the compute statement Press Select (F4), choose Database, then select a field. You can select fields from the primary file, or from files that have a one-to-one relation from the primary file.
    Use the current date in the compute statement Press Select (F4) and choose Current Date.
    Use a constant value in the compute statement Type the value in either numeric or signed notation.
  6. To give the compute field a size, press Size (F6), type the Compute field size, and press Enter.

    If you do not give the field a size, the system determines the type and size of the Compute field based on the types and sizes of the fields used to define it.

  7. Press Enter twice.