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

Get Type Of a Variable

2016-03-17
2018-02-21
  • yannickasselin1 - 2016-03-17

    Hi all,

    Is it possible to get the type of a variable during runtime?

    Something like : typeof in C# ?

    Thank you.

     
  • Ralph Holz - 2016-03-17
    //Declaration
    VAR
    Β  Β MyVarInfo: __SYSTEM.VAR_INFO;
    Β  Β MyTestVar: INT;
    END_VAR
    //Code
    MyVarInfo:= __VARINFO(MyTestVar);
    //after this line of code MyVarInfo contains all information obout this variable - just watch in online mode and you will understand
    

    BR
    Ralph

     
  • yannickasselin1 - 2016-03-18

    Thanks, it works fine!

    But how can someone get some info about these special functions?

    I cannot find anything about it in the help.

    Thank you.

     
  • TimvH

    TimvH - 2016-03-18

    Hi Ralph,

    Thanks for the tip. This is very useful!

    Tim

     
  • singleton - 2016-03-19

    yannickasselin1 hat geschrieben:
    Thanks, it works fine!
    But how can someone get some info about these special functions?
    I cannot find anything about it in the help.
    Thank you.

    Type "System." e.g. inside a ST Editor to come to those fancy stuff

     
  • jzhvymetal - 2017-02-23

    Ralph Holz hat geschrieben:

    //Declaration
    VAR
    Β  Β MyVarInfo: __SYSTEM.VAR_INFO;
    Β  Β MyTestVar: INT;
    END_VAR
    //Code
    MyVarInfo:= __VARINFO(MyTestVar);
    //after this line of code MyVarInfo contains all information obout this variable - just watch in online mode and you will understand
    

    BR
    Ralph

    Is there anyway to get a structures variables members without knowing them? Meaning if you pass a structure to _VARINFO how can you get info about it members?

     
  • josepmariarams - 2017-02-23

    If internals variables are exported to symbolic comunication, I am thinking that you want is posible via cmpiecvaracces.

    But i have not found information about that library.

    I have could see information, using cmpiecvaraccesd, of program variables but not about fb members

     
  • r.zarei2010 - 2018-02-21

    Josep M. Rams hat geschrieben:
    If internals variables are exported to symbolic comunication, I am thinking that you want is posible via cmpiecvaracces.
    But i have not found information about that library.
    I have could see information, using cmpiecvaraccesd, of program variables but not about fb members

    Hi, would you please post how to use iecvaraccess.

    Thanks

     
  • r.zarei2010 - 2018-02-21

    jzhvymetal hat geschrieben:
    Is there anyway to get a structures variables members without knowing them? Meaning if you pass a structure to _VARINFO how can you get info about it members?

    Hi,
    This is exactly what i need, did you find any workaround?

    Thank you

     

Log in to post a comment.