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