There is a problem when u define an enum
in a method
.
I was trying to do this:
VAR
enumA:(A,B,C);
END_VAR
and there is the compiler reaction when I used this in TwinCAT3 Shell
(TcXaeShell).
any help would be appreciated.
There is a problem when u define an enum
in a method
.
I was trying to do this:
VAR
enumA:(A,B,C);
END_VAR
and there is the compiler reaction when I used this in TwinCAT3 Shell
(TcXaeShell).
any help would be appreciated.
You can only use global enumerations in methods. It's one of the limitations with local enumerations.
You should first define variable type as enumeration in DUT
TYPE MyEnum:
(A, B, C)
END_TYPE
Then in a program you can declare variable of that type
VAR
enum: MyEnum;
END_VAR
Inside the program if you want to compare it.
IF enum = MyEnum.C THEN
// Do something
END_IF;
I’ve run into this issue before. You must declare the local enumeration in the variables section of the function block. Then you can use it in the methods of the function block.