07-28-2017 04:50 AM
Hello everybody,
I did a code where a main VI call and open some subVIs.
In order to compact the code, I replaced the standard case structure where each subVI is located in a case with a call by reference.
The problem is in the executable distribution because I don't have to leave the subVI source codes in the distribution for protection reasons.
The executable of the call by reference structure doesn't work when I delete the subvis.vi....obviously.
do you have any advice on how to solve it?
Thanks in advance and have a great summer.
Lucio
Solved! Go to Solution.
07-28-2017 10:51 AM
You need to
!) include subVIs into exe as always included. They will be packed into exe in the same relative location, as in project.
2) Use path to the subVI to open reference, not vi name. VI is not in memory, LV does not know how to get it. Not to have issues with copying exe (absolute full path will change) I usually build path relative to main vi.
07-28-2017 10:55 AM
Another option is to use static references. Instead of building an array of strings with the names of the VIs, build an array of static VI references. The static reference constants will force your VIs to be loaded into memory, and you won't have to worry about keeping the string constants matched to the VI names.
(You could also combine the two approaches - place the static references somewhere on your block diagram to force them to be included and loaded into memory, and then use your existing string-based approach, but that seems silly - if you're already putting static references on your block diagram, might as well make them into an array.)
07-28-2017 10:58 AM
Use a static VI reference for the target sub-VIs.
Once a VI is specified by a static references it will be included in the exe.
Ben
07-28-2017 11:46 AM
It looks like you are calling and forgetting the SubVIs since you don't use any of the outputs. If that's the case you can wire 0x80 to the options on Open VI Reference for "prepare to call and forget".
07-28-2017 01:27 PM
It looks like you have plenty of good answers regarding how to properly call these subVIs dynamically. However, I don't see how calling these various subVIs dynamically is doing anything to compact your code. Your classic setup with a case structure seems just as "compact" and is much more straightforward.
-Preston
07-28-2017 06:13 PM
Great Nathand and Ben, exactly what I needed.
Regarding Pherrman advice: the real application is queue based and each subvi has same structure and connector pane (read and write the queue).
Depending on the version of the main VI, the user will have access to a subset of subVI, So I prefer to manage them as an array of reference.
Thanks for all the feedback.
Lucio