FLD_OUT

Figure 1. Syntax

1  FLD_OUT (
1! 1
1 i_start
2  ,
1! 0
1 i_length
3  ,
1! 0
1 o_start
4  ,
1! i_length
1 o_length
5  ,
1 pad
6  )
Note: Commas following the last specified argument can be omitted.

Can be used in FASTREXX procedures.

Overlays the output record with a field from the input record. See OVLY_OUT for a function to overlay the output record with a literal. If the target field length exceeds the source field length, then the source field is padded to the specified length using the pad character. If the target field length is less than the source field, the source field is truncated from the right. On successful execution, also updates the value of OUTPOS to one byte past the end of the field overlaid in the output record.

Returns
A single blank
i_start
Position, in bytes, in the input record at which to start reading the field to be copied. Can be specified as:
Absolute position
Must be a positive integer. Default value is 1.
Relative to current INPOS
Can be specified as IPx or INx, or as Px or Nx. Must resolve to a positive integer.
Relative to current OUTPOS
Must be specified as OPx or ONx. Must resolve to a positive integer.
i_length
Length, in bytes, of the source field. Must be a non-negative integer. Defaults to 0. If you omit i_length or specify zero, the remainder of the input record from the i_start position is used. This also applies if you specify a value that would cause the source field to be read from beyond the end of the current input record.
o_start
Position, in bytes, in the output record at which to start overlaying the copied field. If you omit o_start or specify zero, the field is appended to the end of the output record. If o_start is greater than the current length of the output record, the record is padded with the specified or defaulted pad character from the current record length to the specified start position. Can be specified as:
Absolute position
Must be a non-negative integer. Default value is 0.
Relative to current INPOS
Must be specified as IPx or INx. Must resolve to a positive integer.
Relative to current OUTPOS
Can be specified as OPx or ONx, or as Px or Nx. Must resolve to a positive integer.
o_length
Length, in bytes, of the target field. Defaults to the source field length (i_length). A value of 0 indicates that the target field length is the greater of i_length and the remaining output record length. If 0 is specified for both o_start and o_length, then i_length is used as the target length.
pad
Pad character. Defaults to the pad character set on the File Manager System Processing Options panel (when processing online) or the pad character specified in the SET function (when running in batch). If the current pad setting is OFF or unspecified, the default pad character is a blank.

Example 1

Copy the characters in columns one and two of the input record to columns three and four of the output record.

  FLD_OUT(1,2,3,2)

Example 2

Append the characters in columns eleven and twelve of the input record to the end of the output record, padded with two blanks.

  FLD_OUT(11,2,0,4,' ')

Example 3

Search a field in the input record for the characters 'AA' and, if found, copy to the end of the output record (assumes that OUTPOS is still set to end of output record).

  IF FLD_CO(10,2,C,'AA') Then
  /* when successful, updates INPOS to 12 */
   FLD_OUT(N2,2,P0,2)
  /* copies from INPOS - 2, appends to end of output record */