Edit Anything

Professional text and hex editing
with Binary Templates technology.



SweetScape Knowledgebase

KB1023: How do convert an enum value to a string?

The special EnumToString function can be used to convert an enum to a string. This function works in two different ways: it can be used to convert an enum value to a string (in the example below FIRST is converted to "FIRST"), or it can also be used to convert an enum variable to a string (in the example below myenum is converted to "SECOND").

    enum MYENUM { FIRST, SECOND };
    local MYENUM myenum = SECOND;
     
    Printf( "FIRST ='%s'\n", EnumToString( FIRST ) );
    Printf( "myenum='%s'\n", EnumToString( myenum ) );

The above code prints out the following results:

    FIRST ='FIRST'
    myenum='SECOND'

This function is especially useful in custom read functions which need to return a string value.





Newsletter - Receive special offers, tips, tricks and news. Join now



010 Editor v15.0 is here!
What's new?


Navigation


Products

010 Editor














E-mail: info@sweetscape.com