From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

List all run-time menu items

Solved!
Go to solution

Hello,

 

If I have a State Machine controlled by a Enum with several items, when I wire the Enum to a Case Structure and select "Add case for every value", the Case Structure will have one Case for each item of the Enum. That simple.

 

Is it possible to have the same behavior with run-time menu items? In other words, can I list all the items into the run-time menu and have this "list" wired to a Case Structure? This would be perfect to avoid hand-typing of every single item.

 

Thanks.

 

Dan07.

0 Kudos
Message 1 of 4
(2,602 Views)

I guess that's not possible for two reasons:

1) The run time menu items change run-time while the cases handled by the case structure cannot.

2) The data type considered is a string. If you wire a string to a case structure all the possibile values are all the possibile combinations of characters....

 

Anyhow, I suppose it's possible through VI Scripting to code a "case structure builder".

For instance it could prepare for you a case structure with a case for every string in a string array.

 

Marco

 

0 Kudos
Message 2 of 4
(2,572 Views)
Solution
Accepted by topic author dan07

This sort of functionality (dynamic, run-time function selection) is simple if instead of a case structure, you use LabVIEW classes with dynamically dispatched VIs to replace the case structure.  Check out the examples in the LabVIEW help and on the NI website to learn the basics of LabVIEW classes.  Pay particular attention to dynamic dispatch.  There are several examples of exactly this type of architecture.  Here is one of them.

 

Note that this type of programming is very different from classic LabVIEW programming and may take a bit to get your head around it.  Once you do, you won't want to go back.

 

Good luck.

Message 3 of 4
(2,570 Views)

Hello,

 

You are right about classes. At first, they are hard to understand, once you do you don't want to go back! I am starting working with them and the code is getting better and cleaner.

 

Thanks.

 

Dan07.

0 Kudos
Message 4 of 4
(2,543 Views)