Return from within a procedure

This may be a simple question, but is it possible to 'return' from within a procedure to the calling program. So ProgramA runs ProgramB which runs ProcedureC. I want to return directly from ProcedureC directly to ProgramA.

Alternatively is it possible to trigger a block of code when returning? Some sort of "on Return do....." I've got multiple times in my program where I'm 'Return'-ing from ProgramB to ProgramA, because of some failed validation etc, and want to make it do some tidying up when it returns, but without hard coding that every time.

Thanks,

SC

You have posted to a forum that requires a moderator to approve posts before they are publicly available.

This may be a simple question, but is it possible to 'return' from within a procedure to the calling program. So ProgramA runs ProgramB which runs ProcedureC. I want to return directly from ProcedureC directly to ProgramA.

Alternatively is it possible to trigger a block of code when returning? Some sort of "on Return do....." I've got multiple times in my program where I'm 'Return'-ing from ProgramB to ProgramA, because of some failed validation etc, and want to make it
do some tidying up when it returns, but without hard coding that every time.

There’s no simple way to do what you want. Throwing errors - or rather, having them propogate their way up the stack – is a common way to do what you want. Make sure you have
BLOCK-LEVEL or ROUTINE-LEVEL directives everywhere when you do this.

The FINALLY block can help with cleanup etc. It’s pretty much always going to run and is good for deleting handles, clearing memptrs and other similar stuff.

You have posted to a forum that requires a moderator to approve posts before they are publicly available.