FLD_TYPE
Note: Commas following the last specified argument can be omitted.
Can be used in FASTREXX condition expressions.
Tests the data type of a field in the input record.
- Returns
- Returns 1 if the test evaluates as True, and 0 if the test evaluates as False.
- start
- Position, in bytes, in the input record at which to start testing.
Can be specified as:
- Absolute position
- Must be a positive integer. Default value is 1. If start is greater than the current length of the input record, the function has no effect.
- Relative to current INPOS
- Can be specified as IPx or INx, or as Px or Nx. If this resolves to a value of less than or equal to zero, the function results in an error. If this resolves to a value that is greater than the current length of the input record, the function has no effect.
- Relative to current OUTPOS
- Must be specified as OPx or ONx. If this resolves to a value of less than or equal to zero, the function results in an error. If this resolves to a value that is greater than the current length of the input record, the function has no effect.
- length
- Length of the field in the input record.
- For packed decimal fields, if you specify the length, it must be in the range 1-16. If you omit the length, FLD_CO attempts to determine the packed field length from the record data.
- For zoned decimal fields, if you specify the length, it must be in the range 1-31 or, if the field contains a separate sign character, in the range 1-32. If you omit the length, it defaults to the remainder of the record. A value of 0 also indicates that the field extends to the end of the record.
- type
- Data type to test for.
- P
- FLD_TYPE returns 1 if the field is a valid packed decimal field. Variant sign values (such as 'f'x for positive) are considered valid. Returns 0 otherwise.
- Z
- FLD_TYPE returns 1 if the field is a valid zoned decimal field. FLD_TYPE recognizes all of the COBOL external decimal variants as numeric data. Returns 0 otherwise.
Example 1
If the first three bytes of the current input record contain a valid packed decimal number, tally the field. Otherwise, tally the first two bytes as a binary number.
If FLD_TYPE(1,3,P) Then
TALLY(1,3,P,'Tally packed')
Else
TALLY(1,2,B,'Tally binary')
Example 2
If the three bytes starting at the current INPOS in the input record contain a valid packed decimal number, copy the three bytes to the end of the output record. Otherwise, copy the two bytes starting at INPOS to the end of the output record.
If FLD_TYPE(P0,3,P) Then
FLD_OUT(P0,3,P0,3)
Else
FLD_OUT(P0,2,P0,2)
Note: In this example, the abbreviated form of the relative position
specification can be used in both arguments of the FLD_OUT function.
This is because i_start naturally targets
the input record and o_start naturally targets
the output record.