Through the "Diagram property" of a given VI, you can access to the array of the references of all the SubVIs it contains. (Scripting purpose).
But I can't figure out, how an instance of a VI (in another VI diagram) could return its own subVI refnum.
I mean, I have N instance of a same VI in a diagram, and I would like each of them to returns as a result, its own subVI reference.
Sorry for my poor english... so I post a VI that explains better what I mean (I hope !).
Hope this is clear enough...
Solved! Go to Solution.
I try to be as clear as possible :
I need the reference of the subVI "block" that is sitting on the block diagram (and not of an instance of the subVI that is occupying space in memory).
To give an example, let's take a look at the following diagram. There's several instance of my "famous" VI which should return it's own subVI reference.
Here, I just want one of the instance of my subVI to be "put in evidence" (sorry it's a french LabVIEW that I have).
This is just an illustration of what could be done... once again, my real need is a little bit longer to explain...
I do not see any simple possibility, sorry.
I hoped to be able to identify instances of reentrant VIs, but the properties of a SubVIs element do not tell me anything about the instance. The "VIName" is the name of the VI, not of the instance, and "VIReference" is the reference to the main instance.
The only other (ugly) approach I could think about is using the "Execution Highlight Object" property of the top level diagram. But this property seems to only return the object when the parent VI does run with "Highlight Execution" enabled and in single stepping, so not really helpful. (There are scripting methods for highlighting, pausing and so on, but ...)
By the way, to also get the SubVIs not in the top diagram, use "Traverse for GObejcts.vi" (in menu "Application Control"/"VI Scripting").
Possible work around: The VI has an input that is wired to a unique constant. The constant a SubVI is connected to can be found by scripting, its value can be compared to the input value. (The uniqueness of the constants [in one caller VI] is done manually or by another scripting VI.)
Because a picture paints a thousand words, here the SubVIs code:
Of course the type of the CONSTANT can be something different than a string.
You could get rid of the constant and just put an indicator on the panel (NOT connected to the connector pane). Every time the subVI starts running, use an LV2-style global to get a unique sequence number and populate that indicator. Not ideal, but probably a lot better than having to make sure all the constants on your diagram are unique.
I don't see at all how you could achieve this... !!!
I don't see any access to such things through the methods and properties of a subvi reference...
Forgive me for getting your hopes up... I thought I had an existing code snippet that did this, but I was wrong -- it was a broken code snippet that wanted to do this but failed.