ENUMERATIONS codesys2.3

mawaloc
2022-11-06
2022-11-07
  • mawaloc - 2022-11-06

    Hello, I've an issue that I'm trying to solve out, and don't know where I'm wrong.
    On codesys 2.3 , I'm trying to use ENUMRATIONS.

    TYPE DisplayVisuPage :
    (STRUCT
    END_STRUCT
    )
    (
    PAGE1 := 0,
    PAGE2 := 1,
    PAGE3 := 2,
    PAGE4 := 3,
    PAGE5 := 4,
    PAGE6 := 5,
    PAGE7 := 6,
    PAGE8 := 7,
    PAGE9 := 8
    );
    END_TYPE

    Then my issue is in a FB
    as variable I have
    DisplayPage: DisplayVisuPage;
    Vara: BOOL;

    My problem is that I've a fault message saying " No number or needs constants"

    when I write similar as below:

    IF DisplayPage. PAGE3 THEN
    Vara:=True;
    END_IF

    I know that if I write , it's gone a be OK , but it's not what I want to do

    IF DisplayPage =2 then
    Vara:=True;
    END_IF

    I believe I have an issue on how Ihave right my ENUM but don't know why. What I've seen is that I can't change the datatype of my ENUM exept to get fault message.

    Thanks for the help.

     
  • Erik BΓΆhm - 2022-11-07

    Hi
    The ENUM definition is wrong.

    Try this:

    TYPE DisplayVisuPage :
    (
    PAGE1 := 0,
    PAGE2 := 1,
    PAGE3 := 2,
    PAGE4 := 3,
    PAGE5 := 4,
    PAGE6 := 5,
    PAGE7 := 6,
    PAGE8 := 7,
    PAGE9 := 8
    );
    END_TYPE

     

Log in to post a comment.