Get Symbol Name as a String

Anonymous
2016-09-07
2016-09-29
  • Anonymous - 2016-09-07

    Originally created by: flogir

    Hello,

    Is there a way to get a string which is the name of the variable passed in parameter of a function ?

    I test the type ANY (__System.AnyType) which provides 3 fields (pointer to the value, value size and type class) but not the name of the value.

    For example :

    FUNCTION func
    VAR_INPUT
       info : ANY;
    END_VAR
    VAR
       infoSize:DINT;
       infoTYPE:__SYSTEM.TYPE_CLASS;
       infoPointer:POINTER TO BYTE;
       infoName : STRING;
    END_VAR
    infoSize := info.diSize;
    infoTYPE := info.TypeClass;
    infoPointer := info.pValue;
    infoName := "" //???????????????????????
    
    func(GVL.myVar);
    

    Now, I would like to retrieve, in my function func, the name of the variable "GVL.myVar".
    I heard about __VARINFO, however I can't find a easy way to retrieve such an information.

    Please help

    Regards,

    FG

     
  • Anonymous - 2016-09-07

    Originally created by: flogir

    The attribute 'parameterstringof' is only available in visu, it's to bad because it whould have solved the problem....

    FUNCTION func
    VAR_INPUT
       info : ANY;
    END_VAR
    VAR
       infoSize:DINT;
       infoTYPE:__SYSTEM.TYPE_CLASS;
       infoPointer:POINTER TO BYTE;
       {attribute 'parameterstringof' := 'info'}
       infoName : STRING;
    END_VAR
    infoSize := info.diSize;
    infoTYPE := info.TypeClass;
    infoPointer := info.pValue;
    
     
  • josepmariarams - 2016-09-29

    See this post
    l viewtopic.php?p=14404#p14404 l

    Varinfo gives to you class name and instance name.

     

Log in to post a comment.