How to get instantiating procedure of class - Forum - OpenEdge General - Progress Community

How to get instantiating procedure of class

 Forum

How to get instantiating procedure of class

This question has suggested answer(s)

All,

I need to know from within a class what procedure instantiated it, similar to this-procedure:instantiating-procedure.  Is there a way of doing this from within a class?  

Thx.

All Replies
  • There is no solution that does not smell buggy ... you can refer to the SOURCE-PROCEDURE handle in the constructor.

    But if you need that for callback reasons, I'd rather pass the handle of the procedure to the Constructor.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • Why do you need this information?

  • I'll look into it, I need it for a call back.

  • Using SOURCE-PROCEDURE from within a class is not really "sanctioned" behavior.  It was never intended to work and the ability to do this may some day go away!  As Mike said, you should have a method/property in the class that the caller can use to set the handle to the caller if that is necessary.  

  • Yes, I've come to that conclusion.  Thanks everyone.

  • You can maybe use call stack

      METHOD PUBLIC STATIC CHARACTER GetCallStack():

         DEFINE VARIABLE cCallStack AS CHARACTER NO-UNDO.

         DEFINE VARIABLE orgStackTrace AS LOGICAL {&API-LOGICAL-FORMAT} NO-UNDO.

         orgStackTrace = SESSION:ERROR-STACK-TRACE.

         SESSION:ERROR-STACK-TRACE = TRUE.

         UNDO, THROW NEW AppError("Throw to get error":U, 0).

         CATCH e AS Progress.Lang.Error:

            RETURN e:CallStack.

         END CATCH.

         FINALLY:

            SESSION:ERROR-STACK-TRACE = orgStackTrace.

         END FINALLY.

      END METHOD.

  • Forget about callbacks and just use events ;) 

    Marian Edu

    Acorn IT 
    +40 740 036 212

  • Well said Laura, that begs the question… what is the etiquette there, why was that even added in the first place? 

    Time for a @deprecated annotation maybe? :)
     
    Marian Edu

    Acorn IT 
    +40 740 036 212

  • I am sure Gilles could implement a SonarSource rule overnight ... Disallow SOURCE-PROCEDURE in Classes.

    Sent from Nine

    Von: "marian.edu" <bounce-marianedu@community.progress.com>
    Gesendet: 12.09.2017 17:47
    An: TU.OE.General@community.progress.com
    Betreff: RE: [Technical Users - OE General] How to get instantiating procedure of class

    Update from Progress Community
    marian.edu

    Well said Laura, that begs the question… what is the etiquette there, why was that even added in the first place? 


    Time for a @deprecated annotation maybe? :)
     
    Marian Edu

    Acorn IT 
    +40 740 036 212

    View online

     

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

    Flag this post as spam/abuse.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • It was never "added".  It is a non-intentional result of the implementation and it was an oversight that we did not disallow it when we introduced OO.

  • That is when used with OO but even in procedural the whole SOURCE-PROCEDURE thing is equally bad probably… the same rationale do apply just fine there as well, why do you care who is calling you? :)

    Marian Edu

    Acorn IT 
    +40 740 036 212

  • FYI a Sonarqube rssw-oe-main:source_procedure rule exists now and it links back to this discussion