Vai al contenuto

How to initialize a structured type variable

Home Forum Programmazione IEC 61131 (LogicLab) How to initialize a structured type variable

Stai visualizzando 3 post - dal 1 a 3 (di 3 totali)
  • Autore
    Post
  • #81752
    George
    Partecipante

    My question is about the way in LogicLab (v10.0.0) when I declare a variable of structure type to set initial values to the elements of a structure that are structure type.

    For example:

    sX: STRUCT
        a : INT;
        b : REAL;
    END_STRUCT;
    sY: STRUCT
        c : BOOL;
        d : DWORD;
    END_STRUCT;
    str: STRUCT
        x : sX;
        y : sY;
    END_STRUCT;
    sVar:str
    #81754
    Sergio Bertana
    Amministratore del forum

    Following your example in the Init value field of the sVar declation you must define the init values as reported

    VAR
        sVar : str := (
    x:=(a:=100, b:=1.7),
    y:=(c:=TRUE, d:=16#12345678)
    );
    END_VAR

    In the screenshot you can see the program with the declaration and during the program execution the values on watch window.

    As you see I used the variable sVar in the program to enable LogicLab to init it. If not used in the program it has not initialized. The variable sVar.x.a is increased at first program loop execution so it init value of 100 has becomed 101.

    #81762
    George
    Partecipante

    Thank you very much. this was the information I was missed. It was not so clear in the LogicLab manual (6.6.7 SETTING VARIABLES INITIAL VALUE).

Stai visualizzando 3 post - dal 1 a 3 (di 3 totali)
  • Devi essere connesso per rispondere a questo topic.