09-27-2012 07:47 PM
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.
Solved! Go to Solution.
09-28-2012 08:19 AM
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
09-28-2012 08:30 AM
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.
10-02-2012 03:38 AM
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.