This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reading enum names as strings in DSS javascript

Hi All,

When i use the function debug_session.expression.evaluate() to get the value of a variable of enum type, i get the numerical value. But what if i actually want the name of the enum value that should be returned as a javascript string ? In code composer i am able to get the names of the enum values in the watch expressions. So is it possible to do it in dss javascript ?

Thanks in advance,

  • Hi Omar,

    Can you send me a small code snippet? I'd like to see how the enums are defined, how they are used and what expression you are evaluating.

    Thanks

    ki

  • Suppose i have an enum like this :

    enum State
    {
    IDLE,
    RUNNING,
    PAUSED,
    };

    And i have a global variable from this enum like this :

    State state_1 = PAUSED;

    Now in DSS when i write this :

    debug_session.expression.evaluate("state_1")

    I will get 2 in the returned value. But i don't want the numerical value 2. I want the string "PAUSED". Is there any alternative for evaluate() method that works for enum values ?

  • Thanks for the example. Looking at the DSS APIs, I don't think there is a way to get the enum value like you are looking. If I find something I will let you know but so far I only see a way to return the actual value.

    ki