LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call by reference and EXE

Solved!
Go to solution

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.

 call by reference Vs Casecall by reference Vs Case

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

0 Kudos
Message 1 of 7
(4,809 Views)

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.

0 Kudos
Message 2 of 7
(4,756 Views)
Solution
Accepted by topic author LucLuc

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.)

Message 3 of 7
(4,752 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 7
(4,750 Views)

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".

Message 5 of 7
(4,744 Views)

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

0 Kudos
Message 6 of 7
(4,735 Views)

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

 

0 Kudos
Message 7 of 7
(4,714 Views)