09-17-2010 12:59 PM
Is there any easy way to tell if a VI is running standalone or if it was called by some other VI?
I have same VIs that are usually called by another VI. But for testing purposes, I would also like them to be able to be run standalone. Unfortunately, these VIs may have some setup requirements, inputs, queues and things that they do not need when they are called.
If the VI can tell if it is running standalone, then it can do some default initialization that is otherwise not needed, so that it can run standalone.
THANKS for your help and suggestions.
Solved! Go to Solution.
09-17-2010 01:03 PM - edited 09-17-2010 01:08 PM
If I remember right the call chain funtion should just contatin one element if the vi is not called as a subvi or with the call by reference node. Using the Run VI method on a VI reference should have only one element in the call chain.
09-17-2010 01:04 PM
You can look at the VI hierarchy under view in the top menu bar.
09-17-2010 01:18 PM
VI reference >>> property node >>> Exec.State
if value is "Run Top Level" then ...
Ben
09-17-2010 01:23 PM
I guess you're aware of this method, but I'll suggest it anyway.
If your VI has connectors they will have the default value when left unconnected. For instance if you have a queue control which is passed when called as a subVI this control will be "not a reference" when you run it standalone.
So by checking the control values you can determine whether valid values are passed. If not, you can do the initialization.
01-31-2014 06:38 AM
This works really well and is much more robust than checking whether your connector values are their default ones or not.
The attached vi works on this principle and returns true if the vi reference passed into it is a top level/standalone application.