Return from within a procedure - Forum - OpenEdge Development - Progress Community
 Forum

Return from within a procedure

This question is not answered

Hi,

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

All Replies
  • For tidiyng up, you should have a look at finally blocks. To return a status from procedure C to B, use output parameters. For returning error states, undo, throw new AppError ("some return value").

    Sent from Nine

    Von: scosens <bounce-scosens@community.progress.com>
    Gesendet: 14.08.2017 18:00
    An: TU.OE.Development@community.progress.com
    Betreff: [Technical Users - OE Development] Return from within a procedure

    Update from Progress Community
    scosens

    Hi,

    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

    View online

     

    You received this notification because you subscribed to the forum.  To stop receiving updates from only this thread, go here.

    Flag this post as spam/abuse.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • 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.