Unknown Sintax error

Riccardo
2021-12-22
2021-12-23
  • Riccardo - 2021-12-22

    Hi guys,

    I am still studing codesys system, I solved many trouble I had but I find always new trouble...
    Melius est abundare quam deficere 😊

    Well, I explane the situation:
    I created an array of type StrArr, a STRUCT with several data of different nature to create a custom datalogger with WSTRING,BOOL, DATE and TIME variables.
    I am showing it, in the visu section, throughout a table, https://help.codesys.com/webapp/_visu_elem_table;product=core_visualization;version=3.5.17.0#element-property-columns
    In the column 0, that points to the FlagAllarme variable of the STRUCT, I am tring to use the template option.
    I would like to show a rectangle, in that column, that changes its color (red/green) on the base of a boolean variable conteined in the StrArr STRUCT.

    I paste a bit of code to help the understaing ( I apoligeze for the italian comment).
    This is the struct:

    TYPE StrArr :
    STRUCT
        FlagAllarme : BOOL;
        DataDiAccesso : DATE ;
        OraDiAccesso : TIME;
        OperatoreLoggato : WSTRING;
        Evento : WSTRING;
    END_STRUCT
    END_TYPE
    

    The following is the PRG I call to write into the array:

    PROGRAM DataLogger
    
    VAR_INPUT
        vEvento : WSTRING;  // Evento da registrare nel data loggher
        AlarmFlag : BOOL;   // Flag di distinzione tra allarmi e semplici eventi
    END_VAR
    
    
        LogArr[indice].FlagAllarme := AlarmFlag;    // Flag di allarme 1 se allarme 0 se manovra
        LogArr[indice].DataDiAccesso := DT_TO_DATE(PLC_PRG.dtSystemTime);   // acquisizione data
        LogArr[indice].OraDiAccesso := DT_TO_TIME(PLC_PRG.dtSystemTime);    // acquisizione ora
        LogArr[indice].Evento := vEvento;   // Acquisizione evento
        LogArr[indice].OperatoreLoggato := VisuElems.CurrentFullUserName;   // acquisizione operatore loggato
        indice := indice + 1;   // incremento dell'indice dell'array
    

    Now the trouble is when I put the "COLOR VARIABLE" in the visu secion I write the several line but no one of them works.

    DataLogger.LogArr[].FlagAllame
    DataLogger.LogArr[DataLogger.indice].FlagAllame
    DataLogger.LogArr[DataLogger.indice].FlagAllame = 0/1

    the compiler gives me always the same error:

    C0007: Expression expected instead of ']'

    If I put this:

    (DataLogger.LogArr[DataLogger.indice].FlagAllame = 0/1)

    The application runs but the colors doesn't switch.

    Does someone know where the error is?

    Many thanks,

    Riccardo

     

    Last edit: Riccardo 2021-12-22
  • Fless

    Fless - 2021-12-22

    by default the string value of struct member is put in the table field
    via Text variable :: DataLogger.LogArr[INDEX].FlagAllame

    just put this in the property Toggle color:

    DataLogger.LogArr[INDEX].FlagAllame
    
     
    πŸ‘
    1
  • Riccardo - 2021-12-23

    Hi Fless thanks for the reaply,

    You are great!!!
    I didn't find nothing about INDEX variable, but it works properly.

    Many Thanks.

    I wish you very good Celebrations.

    Riccardo

     

    Last edit: Riccardo 2021-12-23

Log in to post a comment.