how to check which of union's field is chosen in TTCN

103 Views Asked by At

I have this snippet of TTCN code:

type union MyUnion {
    integer kuku,
    charstring ryku
}
(...)
var MyUnion unia;
unia.kuku := 15;

Now I want to check which of union field(kuku or ryku) is set. How can I achive that?

1

There are 1 best solutions below

0
gusgonnet On BEST ANSWER

you can use the ischosen() function.

Example:

if ( ischosen(unia.kuku) ) {
    log("kuku is chosen");
};

This works fine at least in Titan TTCN. you can find more info about Titan here.

Gustavo.