If operator
The if operator is used to specify the conditions under which the current data field should be tested. This allows the user to test the current data field only if a different field indicates that the test is relevant.
The format of the if statement is:
If FIELD:record type, offset, length, type in {set of values}
value in {second set of values}where: - record type
- Indicates the previous record type in which to look for the field. If the record type is the same as the current record, the field from the current record is used.
- offset
- Contains the offset of the referenced field.
- length
- Contains the length of the referenced field.
- type
- Indicates the type of comparison to be done:
- N
- Indicates comparisons are done as a number. All values are converted to numeric before being compared.
- D
- Indicates comparisons are done as a date. It has the same available features as a numeric field.
- A
- Indicates comparisons are done as a string.
- set of values
- The list of valid values for the field that is specified by the record type, offset, and length values provided to this operator.
- second set of values
- List of valid values for the current data field being tested.
In this example, if the first two characters in the previous, or current, type 20 record are AB or CD, the
value of the field being tested must be 1 or 2.
If FIELD:20, 1, 2, A in {AB | CD} value in {1 | 2 }Any of the value sets previously defined may be used. In this example, if the first two characters in the
previous, or current, type 20 record are AB, GH, N1 through N9, or the same as the two characters starting at
offset 3 in the previous type 25 record, the field being tested must be 1, 2, 4 through 6, or the same as the
character at offset 5 in the previous type 32 record.
If FIELD:20, 1, 2, A in {AB | FIELD:25, 3, 2 | GH | N1-N9}
value in {1 | 2 | 4-6 | FIELD:32, 5, 1}In this example, if the first two characters in the previous, or current, type 20 record are AB, GH, N1
through N9, or the same as the two characters starting at offset 3 in the previous type 25 record, the field
being tested can have any value.
If FIELD:20, 1, 2, A in {AB | FIELD:25, 3, 2 | GH | N1-N9} value in {…}In this example, if the first two characters in the previous, or current, type 20 record are converted to a
number and the number is 1, 2, or in the range 10 to 15, the value of the field being tested must be A or B.
If FIELD:20, 1, 2, N in {1 | 2 | 10-15} value in {A | B }In this example, if the field on the 25 record has a 5-3 format, the value of the field being tested must
also have a 5-3 format. For details on the MATCH operator, see Regular Expression
Operator.
If FIELD:25,19,9,N in {MATCH:\d{5}-\d{3}} value in {MATCH:\d{5}-\d{3}}