82 views
in Embedded Wizard Studio by
Hi

for better handling readability i want to use a const as a switch case

but i get the error :The constant 'Res::DDS1RIGHT' in the 'case' statement has multiple variant values. No multi-variant constants are allowed here.

i have a multi variant project, is it possible to define this const as non-variant?

Thank you

1 Answer

0 votes
by

Hello StephanGeisser,

the switch-case statement expects that the values in case are constant and immutable at the runtime. The error message indicates that the constant Res::DDS1RIGHT may assume different values depending on the language (multi lingual constant) or style (dynamic variant). You can consider it as a constant with multiple (constant) values which are selected dynamically at the runtime.

i have a multi variant project, is it possible to define this const as non-variant?

For this purpose, don't derive any variants from the constant Res::DDS1RIGHT and don't assign any language specific values to this constant. Only the 'Default' value should be initialized.

I hope it helps you further.

Best regards

Paul Banach

by

hi, 

unfortunately that doesn't help me. the moment I drag a constant into the unit it already has all language variants. These are empty. But i still get a error

 

 

Regards 

Stephan Geisser

 

by
Hello Stephan,

do you possibly work with a version older than 12? With version 12 we have improved the handling of constants.

Best regards

Paul Banach
by
Hallo Paul,

12.05 IDE and .ewu file the constant is saved and the .ewu const is used

Regards Stephan
by
Hello Stephan,

I was able to reproduce the issue. It seems that it occur when the constant is declared with an enum as its data type. Using e.g. an int32 as type (and accordingly numbers as values for the constant) works. We have to investigate the cause of the problem. Hopefully we can fix it in the next version.

As workaround: use if-else statements instead of switch-case.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...