LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

detecting whether vi has been called or run

    Ok, I must have missed something because I can't figure out how to detect whether a VI has been RUN (i.e. is a top-level VI) or has been called from another VI. I can get at the "Callers" VI server property to see if the array is empty or not, but if any VI that calls the VI in question is in memory at all, it gives a false positive. The "First Call?" VI is useless too since it gives a "true" whether the VI is top-level or has been called from some other top-level VI.

Am I missing something obvious?
0 Kudos
Message 1 of 3
(2,450 Views)

Hi

I can't give you a solution like an existing property you've missed or something similar, but here's a little workaround:

Just create a boolean control on the front panel, connect it as an input to the connector pane and hide it. If you then call this vi from another vi, just wire a true constant to this boolean. If you leave the vi, reset it, so that it is false before you call it the next time.

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 3
(2,446 Views)

"lanmat" <x@no.email> wrote in message news:1154589007874-399778@exchange.ni.com...
&nbsp;&nbsp;&nbsp; Ok, I must have missed something because I can't figure out how to
detect whether a VI has been RUN (i.e. is a top-level VI) or has been
called from another VI. I can get at the "Callers" VI server property
to see if the array is empty or not, but if any VI that calls the VI in
question is in memory at all, it gives a false positive. The "First Call?" VI is useless too since it gives a "true" whether the VI is top-level or has been called from some other top-level VI. Am I missing something obvious?



Hi,


The Callers property returns all vi's in memory that call the vi. So that won't work.


Try the Call Chain function. If there is only one element, the vi (the current run of it) is top level.


You can also use the property "Execution>State", which returns "Running" or "Running Top Level". But the call chain is easier.


Remember, if you put the call chain code in a sub vi (you should) you have to check if there are two elements!


Regards,


Wiebe.



0 Kudos
Message 3 of 3
(2,427 Views)