LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a Sub VI using Static Reference

Solved!
Go to solution

I am attaching a Zip file which is a sample call of a Sub VI from Main VI. This uses relative paths and VI Server to load the Sub VI. 

 

Just want to know how to do the same thing using Static VI reference.  Some of the settings in that process are not clear and hence the query. I guess its far more efficient way to do this instead of with relative paths ? 

 

TIA. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 8
(6,245 Views)
Solution
Accepted by topic author MogaRaghu

Have you tried the Start Asynchronous Call function?  I stopped using VI Server shortly after Start Asynchronous Call was added to LabVIEW (around 2010, perhaps?).  I urge you to try this:

  1. Drop a Static VI Reference.
  2. Right-click, change to Strictly-Typed, then Browse for Path to the VI you want.  It really helps to give your sub-VIs a recognizable VI Icon (the Icon you see here is the Icon you are using for SUBVI01 -- not very mnemonic.
  3. Drop a Property node, and wire the VI Reference to its input.  Change property to VI Path.
  4. Drop an Open VI Reference.  Wire VI Path to Path from Property Node, connect Error Line to Property Node, and wire (Strict) VI Reference to top "Type Specifier" input.
  5. Right-click the Open VI Reference and select "Help".  Read about the Options input.  You probably want 0x80, "Prepare to Call and Forget".  Wire the Options input appropriately. 
  6. Drop a Start Asynchronous Call function, wire the Error Line and the VI Reference lines from the Open VI Reference.  Notice you'll get (part of) the Connector Block of your chosen sub-VI, which you can use to pass values to the sub-VI when you call it with this function.

One tremendous advantage of this scheme is that it works exactly the same whether in Development Mode or built into an executable.  Here's a Snippet to admire (in LabVIEW 2016):

Start Asynch.png

Bob Schor

Message 2 of 8
(6,238 Views)

Go with Bob's suggestion.  The only thing I'd like to add is that instead of getting the VI Path I generally get the VI Name.  The Open VI Reference works on VI Names (string) or VI Paths (path).  But if the VI isn't saved then there is no path and it will only work on the VI Name.  Not a big deal in a VI that is saved but for quick VIs I'm testing, I may not have saved the VI to disk yet.

Message 3 of 8
(6,216 Views)

Thanks Bob. 

Since I vaguely recalled that I have raised a similar query a few months back, I searched all my posts and could locate a post where you have posted a full project based on the static VI reference.  But what kept me guessing is the fact that you had used the VI Server to get back to Main from the Sub. 

 

Was there any reason to it or it was just done so that the difference is appreciated ? 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 8
(6,185 Views)

Yes I too noticed it from the help file. Its a very convenient thing to just use the name of the VI.

But I was wondering what is going to happen if there are two VIs with the same name ? This can happen when developing code and we have folders with different versions of same code and invariably VI names are same. Or is it that it does not go about searching the whole disk for the name and restricts only to the specified folder ( makes sense this way ) 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 8
(6,183 Views)

@MogaRaghu wrote:

Yes I too noticed it from the help file. Its a very convenient thing to just use the name of the VI.

But I was wondering what is going to happen if there are two VIs with the same name ? This can happen when developing code and we have folders with different versions of same code and invariably VI names are same. Or is it that it does not go about searching the whole disk for the name and restricts only to the specified folder ( makes sense this way ) 


LV requires unique names. If you load a VI with the same name from another folder it can cause all sorts of cross reference hell. Using Path won't solve that.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 8
(6,160 Views)

@MogaRaghu wrote:

But what kept me guessing is the fact that you had used the VI Server to get back to Main from the Sub.  Was there any reason to it or it was just done so that the difference is appreciated ? 


I didn't realize that I'd already given you this better answer several months ago (but I guess you chose not to listen).  I confess I didn't trash all of your code and completely rewrite it for you, causing me to overlook the use of VI Server that you reference.  Sometimes when looking at code that others have written, with no opportunity to talk to them and say "What did you mean to do here, and why did you do it that way?", we focus on One Thing, try to show how to Fix That, and hope that the listener will understand and learn from the experience to fix similar problems themselves.

 

I apologize for the confusion.

 

Bob Schor

0 Kudos
Message 7 of 8
(6,147 Views)

Bob... its me who has to apologize for overlooking the earlier post. 

And just for the records .. irrespective of the impression I have created I do take all responses very seriously. After all forum support is voluntary and the person responding is investing his time on good intention to help. It demands the respect that is due. 

 

In some cases however the recommendations cannot be implemented due to various reasons ( equipment despatched , problem solved otherwise, change in sequence etc etc ) 

 

Thanks for your support. I will now figure out how to use the Static VI reference to go back to Main. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
Message 8 of 8
(6,138 Views)