Input record relative positioning

Z Data Tools allows a FASTREXX program to search an input record and use the resulting successful search position to make other tests at a fixed offset from the located string. You can also perform this task in full REXX, using REXX variables and non-FASTREXX functions. However, it executes more efficiently if done in FASTREXX using relative positioning.

Z Data Tools maintains an internal "current position" in the input buffer, and also sets the value in the REXX variable, INPOS. (Note: you cannot use REXX variables in FASTREXX.)

To set the current position in the input buffer, use the function FLD_CO (Field Contains). If the search operation is successful, the current position is set to the starting byte of the located string.

You can refer to the input buffer position wherever an input or output buffer position is required in a FASTREXX function. You can adjust it positively (for example, P7 is the current position plus 7 bytes), or negatively (for example, N2 is the current position minus 2 bytes).


Print all members of a JCL library which execute a program with a name like %%DBG* (any 2 initial characters and any following allowed). The way this is implemented is to test if the JCL record contains " EXEC PGM=" and then test the program name for "DBG" at a relative position.

If FLD_CO(1, 0, C, " EXEC ") ,
 & FLD_CO(P4, 0, C, " PGM=") ,
 & FLD(P7,3) = "DBG" Then
P = Pos( " EXEC ", INREC, 1 )
If P = 0 Then RETURN
P = Pos( " PGM=", INREC, P )
If P = 0 Then RETURN
If Substr( INREC, P+7, 3 ) = "DBG" Then


(Can't be done.)