|
Assuming that the length of the source string (after execution of the ON-unit, if specified) is k, the starting point is i, and the length of the substring is j:
M = max( I,1 )
N = max( 0,min( J + min(I,1) - 1,K - M + 1 ))if J is specified.
N = K - M + 1if J is not specified.
This means that the new arguments are forced within the limits.
The values of i and j are established before entry to the ON-unit. They are not reevaluated on return from the ON-unit.
The value of k might change in the ON-unit if the first argument of SUBSTR is a varying-length string. The value n is computed on return from the ON-unit using any new value of k.