Specifying relative positions

Relative positioning is specified when you use a special character string, in the form of <type><offset>, in place of an integer in the start argument of a supported function. The relative position can be specified in the following ways:

IPx
The start position is taken from the current INPOS (the “I” in <type>) and then offset a positive (the “P” in <type>) number of bytes, as specified by x. For example, if the INPOS was currently 20 and you specified a start argument of IP5, the start position would be 25.
INx
The start position is taken from the current INPOS and then offset a negative (the “N” in <type>) number of bytes, as specified by x. For example, if the INPOS was currently 20 and you specified a start argument of IN5, the start position would be 15.
OPx
The start position is taken from the current OUTPOS (the “O” in <type>) and then offset a positive number of bytes, as specified by x. For example, if the OUTPOS was currently 20 and you specified a start argument of OP5, the start position would be 25.
ONx
The start position is taken from the current OUTPOS and then offset a negative number of bytes, as specified by x. For example, if the OUTPOS was currently 20 and you specified a start argument of ON5, the start position would be 15.

When the start argument's natural target is the input record, IPx and INx can be abbreviated to Px or Nx.

When the argument's natural target is the output record, OPx and ONx can be abbreviated to Px or Nx.

When the argument's natural target is a variable, IPx, INx, OPx, ONx, can be used to denote the current relative variable position. They can be abbreviated to Px or Nx.

For example, FLD(start_column,length,type) reads from the input record, so you could specify start_column as IP5 or P5 and get the same result. On the other hand, if you wanted to use the current value of OUTPOS to specify the start_column in the input record, you must specify the <type> in full, that is, as OP5.