When INLR is *On the program will finish the current cycle and then exit.
RETURN immedialely exists the program from the spot it is in. INLR does not have to be *ON for this to happen
Setting on LR tells the program what to do after the last statement in the C-specs is run. Executing RETURN exits the program.
Note that executing RETURN will cause it to become the last C-spec that is run.
The program can be exited by executing a RETURN, by falling through the bottom of the C-specs with LR on, or by falling through the bottom of the C-specs with RT on.
The RT indicator will cause an exit at the end of a Cycle whether LR is on or not.
The “Cycle” exists in almost all RPG programs. (There are some exceptions.)
It is like there is a hidden DOUNTIL just before the first C-spec in your program and a hidden ENDDO just after the last C-spec (before the first BEGSR). The condition on the hidden DOUNTIL is something like (*INLR = *ON or *INRT = *ON).
One way to see what the “Cycle” means:<pre>
D NxtCycle s n inz( *OFF )
D LastCycle s n inz( *OFF )
D Cnt s 3p 0 inz( 0 )
C if ( LastCycle = *ON )
c eval *INLR = *ON
C if ( NxtCycle = *ON )
c eval LastCycle = *ON
C eval NxtCycle = *ON
C eval Cnt += 1
</pre>Compile that as RPGLE with full debug. Run it under debug and put a breakpoint on the last statement. See if you can figure out what value Cnt will have in it when the program ends.
Once you figure out what happens, you’ll have a much better understanding of what the “Cycle” is.