Calling a Method in a class dynamicly using dynamic-function - Forum - OpenEdge Development - Progress Community

Calling a Method in a class dynamicly using dynamic-function

 Forum

Calling a Method in a class dynamicly using dynamic-function

This question is not answered

11.3 --> 11.7

After converting to 11.7 the following statement seems to give an error:

User-defined function 'getMsgQueueProperty' invoked dynamically but could not be found. (5639) Procedure:"ProcessMessageReadyIn oomsg.msgQueue"

the statement is:

      dtzDocumentDate            = datetime-tz(dynamic-function("getMsgQueueProperty" in source-procedure,msgQueue.msgQueueGID,'DocumentDate'))

-------------

This is how it is called:

* msgQueue.cls has the Method getMsgQueueProperty.

in msgQueue there is another method that calls:

oDocument = NEW msgDocument(oMeasuringTicket,msgQueue.msgQueueGID).

in msgDocument I need to Call the method getMsgQueueProperty and untill now it has worked using dynamic-function(....

How would I do this now in 11.7 ? I want to Call a method in the Source-procedure (witch is a class).

All Replies
  • Please check out DYNAMIC-INVOKE for class methods.
     
     
    Von: goo [mailto:bounce-goo@community.progress.com]
    Gesendet: Montag, 7. August 2017 12:31
    An: TU.OE.Development@community.progress.com
    Betreff: [Technical Users - OE Development] Calling a Method in a class dynamicly using dynamic-function
     
    Update from Progress Community
     

    11.3 --> 11.7

    After converting to 11.7 the following statement seems to give an error:

    User-defined function 'getMsgQueueProperty' invoked dynamically but could not be found. (5639) Procedure:"ProcessMessageReadyIn oomsg.msgQueue"

    the statement is:

          dtzDocumentDate            = datetime-tz(dynamic-function("getMsgQueueProperty" in source-procedure,msgQueue.msgQueueGID,'DocumentDate'))

    -------------

    This is how it is called:

    * msgQueue.cls has the Method getMsgQueueProperty.

    in msgQueue there is another method that calls:

    oDocument = NEW msgDocument(oMeasuringTicket,msgQueue.msgQueueGID).

    in msgDocument I need to Call the method getMsgQueueProperty and untill now it has worked using dynamic-function(....

    How would I do this now in 11.7 ? I want to Call a method in the Source-procedure (witch is a class).

    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.

  • I have looked at it, but how I am not sure how to Call the Source-procedure ... How do I refere to the Source-procedure's class? Is Source-procedure the handle to the class?

    //Geir Otto

  • Source-procedure is a procedural construct and should not be used for classes ... when calling into a class method, you need to use a reference variable.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • So If I have two classes:

    a.cls

    b.cls

    and in a.cls I call b.cls, how can I refere to class a? Too much vacation here....

  • Hmm, this seems to imply that source-procedure albeit a procedure handle did pointed to an object instance (class) before… probably not supported, still it does seems to confirm my thought of initial OO implementation being just an ‘abstraction’ over existent procedural constructs, namely functions. This not working anymore might mean something changed there so an object instance it’s just not a persistent procedure with a makeup :)

    Anyway, source-procedure should not be there in the first place, whatever you do there should not depends on who made the call but maybe I’m biased here.
     
    Marian Edu

    Acorn IT 
    +40 740 036 212

  • In a:
     
    b:MethodName (THIS-OBEJECT) .
     
    In b:
     
    METHOD PUBLIC VOID MEthodName (referenceToA AS <suitableType>):
     
    The suitableType should be an Interface implemented by a that defines the callback-methods required.
     
    Or – bad style – Progress.Lang.Object and you use DYNAMIC-INVOKE from b to call back into a
     

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • Thanks Mike :-) I allways forget this statement...

  • If I add THIS-OBJECT as a parameter, it gives me an error : Invalid handle. Not initialized or Points to a deleted Object.... How can that be?

  • ooo, by the way Mike, I want to Call a Method in A.cls FROM B.cls.....

    I tried in A.cls

    oB = New b (this-object).

    and in b.cls:

    constructor ....(oA as class a):

    test = oA:theMethod('something,222).

    I get the error saying that oA is invalid....

  • Do you do this
     

    test = oA:theMethod('something,222).

     
    In the constructor? Or in a method?
     
    Constructor parameters are no longer available in methods, so you need to assign that reference value to a variable or property to use this in a method.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • yes the test = oA:method(....) is done within the constructor of B. So, I have to define a variable x as class A ?.

    something like this?

    constructor of b (oA as class A):

    x = oA.

    x:method(....).  // seems a bit strange to do it like this....

    end constructor.

  • I have no idea what you are doing wrong, but this works in 11.3 both from a constructor and a method in a I can instantiate b and run a method in a from it's constructor. I tested it because we had this-object bugs in the past (but that was in 10.2B):

    class a:

     constructor a ():

       new b(this-object, "from constructor").

     end constructor.

    method public void test(input icMessage as character  ):

       message icMessage

         view-as alert-box info buttons ok.  

    end method.

    method public void newbFromMethod():

     new b(this-object, "from method").

     end method.

    end class.

    class b:

     constructor b(input oa as a, input icMessage as character):

       oa:test(icMessage).

     end constructor.

    end class.

    define variable oa as a no-undo.

    oa = new a().

    oa:newbFromMethod().

  • It is a bit strange for me as well. It is a bit tricky to test it since it is in a live Production system running on Linux x64 bit OS, so I can't test it for the moment. I have fixed the problem by doing a workaround....

    The only diff from what you sent is that New b is not running from the constructor of class A, but from a Method in class A....

  • > The only diff from what you sent is that New b is not running from the constructor of class A, but from a Method in class A....

    That's what oa:newbFromMethod() does.

    I also tried making newbFromMethod static since then I would expect THIS-OBJECT to be valid, but then it doesn't even compile so that can't be what you're doing (or something changed in 11.7.)

  • You need to post some code.  I no longer know what you're doing.