Format enum with custom values

Forum Home Forums Understanding the Software Format enum with custom values

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17998
    oley
    Participant

    I have a command to enable/disable switch.
    The values are 0 and 0xFF00.
    Format enums start with a value of 0.
    Is it possible to define an enum with different values, like in C#?

    public enum SwitchState
    {
    Off = 0,
    On = 0xFF00
    }

    #17999
    manjey73
    Participant

    public double exsamp()
    {
    if (Cmd==0) return 0;
    elseif (Cmd==1) return 65 280;
    else return double.NaN;
    }

    there is no On or OFF in Cmd, numeric values are there, even if you use enumerations.

    #18000
    oley
    Participant

    Thanks, I thought about some script but want to ask if there is another option.

    #18001
    manjey73
    Participant

    when you use the Off-On enumeration and the command window has two corresponding buttons, a 0 or 1 is sent to your command as a double. Based on this, it is required to build a formula.

    #18002
    manjey73
    Participant

    Cmd==0? 0 : Bitconverter.Double({ 00, FF, 00, 00, 00, 00, 00, 00})

    this option is also possible. just check the syntax.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.