Defining a Condition Field
A condition field is one of the five types of derived fields that you can define. It consists of conditional statements followed by fields, values, or another conditional statement. Use this procedure to define a condition field.
For more information on condition fields, see Condition Fields.
To define a condition field
- 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).)
- Type a field name and press Tab.
-
In the Element field, type an element name and press Tab.
The Select an Element Type for Element subform appears.
- Select the Cond Field derived type.
-
In the Define Conditional Field Statement subform,
set up the conditional field statement, using the following guidelines.
A conditional field statement must have at least one If (Condition) statement, and one Else statement to complete it. A field, a value, or another If (Condition) statement must follow each If (Condition) statement and each Else statement. The only other restriction is that the entire statement must result in a single value.
Each component of a conditional field statement is described below. You can put these components together in several ways, depending on the desired outcome. Press Insert (F8) to insert lines.
Component Procedure and Description The If ( Condition ) statement Press Select (F4) and choose If.
If the file already has conditions defined for it, the Select A Condition subform appears. Select an existing condition or select New Condition to define a new condition.
If you select New Condition, or if there are no existing conditions for the file, the File Records subform appears. Type a record condition. For more information, see Defining Conditions.
The result Each If or Else statement can have one result. The result of an If (Condition) or Else clause can be a field, a value, the current date, or the current time. Press Select (F4) and choose Field, Value, Current Date, or Current Time.
If you choose Field, select a field for the If (Condition) or Else statement. Fields can be either database values or derived fields.
If you choose Value, define a value for the If (Condition) or Else statement.
If you have not defined a field for the conditional field statement, the Select A Value Type subform appears. Select the desired value type. The Value subform appears. Type a value and press Enter.
The Else Statement Press Select (F4) and choose Else. Note: The Result field must be the same type for the If and Else statements. For example, you cannot choose a field for the If Result and a literal value for the Else Result field. -
To give the conditional field a size, press Size (F6), type the field size, and press Enter.
If you do not give the field a size, the system determines the type and size of the conditional field based on the type and sizes of the fields used to define it.
- Press Enter twice.