EBSILON®Professional Online Documentation
EbsScript / EbsScript Functions / Support Functions
In This Topic
    Support Functions
    In This Topic

    Reflection for enumeration

     

    The functions enumToString and enumStrings serve to access the symbolic names of an enumeration type during the runtime of an EbsScript.

    enumToString

    enumStrings

    serve to access the symbolic names of an enumeration type during the runtime of an EbsScript.

     

    Name

    Purpose

    Arguments

    Return value

    Example

    enumToString

    Returns the symbolic name of value as text.

     

     

    enumToString(value:, format:string = „g“):string;

    • returns the symbolic name of value as text. As format specification, “g“, “G“, “d“, “D“, “x“, and ”X“ can be specified. If the format is blank, “g“ will be used.
      • “g“, “G“: returns the symbolic name of value. If several symbolic names with the same value exist, it is undefined which one of them will be returned. If no such name exists, the numerical value will be returned in decimal notation (see format ”d“).
      • “d“, „D“: returns the value of value in decimal notation.
      • “x“, “X“: returns the value of value in hexadecimal notation. The result has eight places and is possibly completed by leading zeros (NO leading “0x“ will be prefixed). For “x“ a-f will be used and in the case of “X“ A-F will be used for the hexadecimal numerals.

    String: Text of value
                                   

    Example for both functions: 
    enumToString; enumStrings

    var

     func:FuncEnum;
     r:namedindexarray;
     i:integer;

    begin

     func:=FuncH_of_PT;
     println(enumtostring(func));
     func:=FuncHg_OF_Pfg;
     println(enumtostring(func));
     println(enumtostring(FuncEnum(15)));

     func:=FuncXG_OF_PT;
     println("Hexadecimal value of ", enumtostring(func)," is = ",enumtostring(func, "X"));
     
     // get all entries and print out
     println("All entries of FuncEnum:");
     r:=enumstrings(FuncEnum);
     for i:=low(r) to high(r) do
     begin
           println(r[i].name, ":", r[i].index);
     end;
    end;

    enumStrings
    (<enumerations-type>)

    Returns a dynamic array of all symbolic names with their respective value. The type namedindexarray is defined in the unit @System.

    enumStrings: namedindexarray;

     

    See example for enumToString