LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get reference to top level VI

Dear all,

 

I have a VI that calls a subVI which, in turn, calls a subVI. I would like the final subVI to get the reference of the first, top most, calling VI. The call chain function will not work as it returns neither a reference or a path, only the file name. I would prefer not to pass the reference to each VI, rather I would like the final subVI to get the reference (or path and name) of the top most VI. Any ideas?

 

Thanks.

0 Kudos
Message 1 of 4
(5,298 Views)

I would use an Action Engine or Functional Global Variable to store the reference to the top level VI when it first runs.  With that, you can retrieve the reference in any VI.

Message 2 of 4
(5,291 Views)

Call Chain will return an array of strings of the names of the VIs. The last element is the top most VI. Then use Open VI Reference to get a reference of the top most VI. You can just feed to string from the last element into the VI path input of the Open VI Reference.

 

GetTopVI.png

Omar
Message 3 of 4
(5,278 Views)

Both mar and Bill have offered good and proper answers to your question. To help distinguish...

 

Omar's solution is classic KISS and if it serves your needs then go with it.

 

If you app is likely to get a bit more complicated and if there is the possiblity of having to use multipl threads doing background tasks that require interaction with the GUI then I lean toward Bills suggestion. YOu can see some examples of utilizing the Action Engine to allow access to the GUI  in the images I have in this gallery. Note: The images have inks to the original threads if you have follow-up Qs.

 

Ben

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