VAR_OUT
(Can be used in FASTREXX procedures.)
Overlays the output record with a field from the variable. 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.
- name
- A 1–256 character variable identifier. Variable name matching is not case-sensitive. If the name is not found, a variable is created and populated from the current input record.
- i_start
- Position, in bytes, in the variable 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, or 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 variable 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 variable.
- 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 positive integer. Default value is 1.
- Relative to current INPOS
- Can be specified as IPx or INx, or as Px or Nx, or as OPx or ONx. 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 1 and 2 of the variable to columns 3 and 4 of the output record.
VAR_OUT(MYVAR,1,2,3,2)
Example 2
VAR_OUT(MYVAR,11,2,0,4,' ')
Example 3
Search a field in the variable 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 TESTC(MYVAR,'CU','AA') Then
/* when successful, updates variable position to 12 */
VAR_OUT(MYVAR,N2,2,P0,2)
/* copies from variable position - 2, appends to end of output record */