Supported RPG Features

SUBST, SCAN, CHECK, CHECKR and XLATE require a start position of at least 1 and no more than the source's length, and SUBST additionally requires that the length not run past the end of the source. Violating either raises status 00100.

The position is not clamped. A start of 0, a start one past the last character, or a length that overruns the source is an error rather than a shortened result:

      * src is CHAR(10). start is a variable, so this is a run-time check - * a literal out-of-range start is caught at compile time instead.
     C     1             SUBST     src:start     res

Add the (E) extender to trap it. %ERROR is then set on, %STATUS carries 100, the result field is left unchanged, and execution continues:

     C     1             SUBST(E)  src:start     res
     C                   IF        %ERROR
      *                  ... start was outside src; res still holds its old value
     C                   ENDIF

Without (E) the error is unmonitored and ends the program. A MONITOR / ON-ERROR block catches it in either case.

This applies to the fixed-format opcodes only. The free-format %SUBST, %SCAN, %CHECK, %CHECKR and %XLATE built-ins take no (E) extender and keep their own behaviour.