Defining an Array Value Field

Use this procedure to define array value fields.

An array value field can access a specific value in an array or sum the values in an array.

An array is an easy way to keep track of a list of data. For example, a file stores the company monthly balances. Because there are 12 months, you can store each monthly balance in a single field.

Field Name         Occurs     Type       Size
-------------------------------------------------------------------
Balance 1                     Signed     11.2
Balance 1                     Signed     11.2
Balance 1                     Signed     11.2
.
.
.

Alternatively, you can store the balances in an array field that has 12 values (occurs 12 times), one for each month.

Field Name         Occurs     Type       Size
-------------------------------------------------------------------
Balances              12      Signed     11.2

A subscript lets you reference each value in the array. For example, the balance of the first month is subscript 1 of the field Balances; the balance of the second month is subscript 2 of the field Balances, and so on.

The following array value field, Mnth-3-Balance, accesses a specific value (subscript 3) in the array Balances from the Sales file.

You can also use a variable value, stored in a field, to access a specific array value. For example, the array value field Curr-Balance accesses the monthly balance for the current period. The Sales file stores the current period in the Current Period field. The Current Period field can be used to subscript the Curr-Balance array. If the value in the Current Period field is 5, the fifth value of the Balances field is the Curr-Balance.

You can also define an array value range subscript to add values in an array. For example, a subscript of 4 and a range subscript of 6 sums the fourth, fifth, and sixth values in the array field Monthly Sales.

To define an array value field

  1. On the Format form, press Output (F3) and choose Array Value.

    - or -

    On the Report Format form, press Field (F3) and choose Array Value.

    In this field Type or Select (F4)
    Array Value Name A unique name for the array value field.
    Array Field Name

    Press Select (F4) and choose an array field.

    The window displays the number of times the array field occurs in the Occurs field.

    Subscript

    The array by the value of another field, by the result of a compute statement, or by a constant value.

    To subscript the array by a field, choose Field, then select the field type. For a description of each field type, see the table following this procedure.

    To subscript the array by a value, choose Value, then type a value for the subscript. Press Enter or OK.

    Range Subscript

    The end range of a summation array value.

    For example, to add the fourth, fifth, and sixth occurrences of a numeric array field, type 4 in the Subscript field and 6 in the Range Subscript field. Define the range subscript in the same way as the subscript.

  2. Press OK twice.
  3. In the Form Output Field Definition window, change the default attributes, if desired. For more information, see Defining Output Field Attributes.

    The type and sizes of the fields used to define the array value field determine its type and size.

  4. Press OK.

    The field appears on the Format form.

    To label or move the field, see Labeling, Moving, and Deleting Fields..

  5. Press OK twice to save the form.

    The system saves the form and returns to the Database Structure-Program Structure form.

    The following table describes the field types you can use in an array value definition.

    Choose To
    Database Subscript the array by the value of a database field.
    Compute Subscript the array by the resulting value of a compute statement. Select an existing compute statement field or define a new compute statement. For more information, see Defining a Compute Field.