nokia / ntt

Modern tools for TTCN-3
https://nokia.github.io/ntt/
BSD 3-Clause "New" or "Revised" License
71 stars 33 forks source link

Add builtin function enum2int #682

Open michalwypustek opened 1 year ago

michalwypustek commented 1 year ago

enum2int(in Enumerated_type inpar) return integer

This function accepts an enumerated value and returns the integer value associated to the enumerated value. The actual parameter passed to inpar always shall be a typed object.

type enumerated MyFirstEnumType {
    Monday, Tuesday, Wednesday, Thursday, Friday
};
type enumerated MySecondEnumType {
    Saturday(-3), Sunday (0), Monday
};

//within a dynamic language element:
var MyFirstEnumType vl_FirstEnum := Monday;
var MySecondEnumType vl_SecondEnum := Monday;
enum2int(vl_FirstEnum) // returns 0
enum2int(vl_SecondEnum) // returns 1