Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

is there a way to convert pointer to interface reference

kai-sew
2018-11-13
2018-11-14
  • kai-sew - 2018-11-13

    Hello,

    I want to do following things:

    // interface
    itf_base : I_Base;

    // FBs
    FB_A implements I_Base;
    FB_B implements I_Base;

    // create
    IF A THEN
    itf_base := __NEW(FB_A);
    ELSE
    itf_base := __NEW(FB_B);
    END_IF

    The problem is __NEW operator returns a pointer not an interface reference.

    There is an operator to convert interface to pointer "__QUERYPOINTER".

    Is there a way to do the reverse conversion?

    Best
    Kai

     
  • kai-sew - 2018-11-14

    Figured it out myself,

    just need to dereference the pointer ...

     

Log in to post a comment.