RESUME ENDFUNCTION

Added August 2011

The RESUME ENDFUNCTION (or ENDPROCEDURE) statement is meant to resume at the exit point of the routine, but with the introduction (in 5.1.1192/ compiler edit 462) of the explicit Exit Label $EXIT, there was some ambiguity as to which exit point the RESUME was to refer to. Initially, it referred to the $EXIT label (if present), since, after all, the purpose of the explicit $EXIT label was to force the execution of some code prior to exiting the routine, regardless of how the routine was terminated. But, after some field experience, it became clear that this was neither the expected behavior, nor was it particularly safe, since it introduced the possibility of an infinite loop if an error occurred while processing the code following the $EXIT label.

So, as of 5.1.1223 (compiler edit 487), RESUME ENDFUNCTION (or ENDPROCEDURE) resumes at the physical end of the routine, skipping any code following an $EXIT label.

If you really want to execute the code at your $EXIT label upon resuming from an error (and are sure that your code is error-free), you can resume explicitly to that label by specifying it explicitly in the RESUME statement:

RESUME $EXIT

Note that the WITH_ERROR clause is not permitted in this case. It only makes sense when resuming directly to the caller (i.e. ENDFUNCTION/ENDPROCEDURE).