LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String OR enum on the same input (and nothing else)?

Solved!
Go to solution

Hi,

 

is it possible to create a VI which accepts only enums on its input (either typedef or a non-typedef), but makes wire broken if anything else (eg: u16) is connected? Something like as malleable VIs can do it.

 

Thanks.

 

 

0 Kudos
Message 1 of 4
(15,409 Views)

Hi 1984,

 

To my knowledge, only a malleable VI could do that, because a normal VI would allow integers to be connected to the enum input (adding a coercion dot).

 

Here is an example implementation of a malleable VI that only accepts enums:

raphschru_0-1707146052461.png

 - "Split Number" ensures the data type is an integer.

 - "Format Into String" with constant format "%s" forbids plain integers, which leaves only enums as possible data type.

 

Both functions are removed by the compiler through a process called "Dead code elimination", so it won't affect execution memory or performance.

 

raphschru_1-1707146565101.png

 

Regards,

Raphaël.

0 Kudos
Message 2 of 4
(15,390 Views)
Solution
Accepted by topic author 1984

If you also want to allow a string input, just add a Type Specialization Structure in your malleable VI, with another case that only compiles if a string is used:

raphschru_0-1707147566727.png 

raphschru_1-1707147608875.png

 

Regards,

Raphaël.

 

Message 3 of 4
(15,381 Views)

Actually this is exactly what I was looking for! Thanks!

0 Kudos
Message 4 of 4
(15,360 Views)