LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get This VI Clone Reference

Highlighted

So lets say I have a reuse function that setups up my VI's front panel the way I like.  It has an input for the VI reference, that it should be setting up the front panel for, but if you don't provide a reference it will get the calling VI reference using the call chain, and an Open VI Reference.  It then closes this reference after it is done.

 

If I drop this function on a reentrant VI then things could be a bit hairy.  I can still use the call chain to get the name of the clone VI, and I can still use the Open VI Reference with it.  But according to LabVIEW R&D being able to open a new reference to a clone VI is not something that should work due to possible instability.

 

So my question is this, how can I get a reference to a clone VI, from within that clone VI, without explicity passing that reference in, in a safe way?

 

Because this idea exchange idea exists I assume there isn't a way.

0 Kudos
Message 1 of 9
(2,105 Views)
Highlighted

Oh new mild-ly related question for a bonus point.  Is there a way looking at a VI Reference to know if the reference is a This VI reference?

0 Kudos
Message 2 of 9
(2,093 Views)
Highlighted

I guess using VI scripting you could edit calling VI to drop a "This VI" constant, then you could get its value in your subVI....!?

 

I'm not pretending to be an expert, just trying to get bonus points for a tough question 🙂

0 Kudos
Message 3 of 9
(2,067 Views)
Highlighted

You have a GetRefnumInfo in the utility/variant folder. You can see that it's a VIref, but not specifically a this vi. For that i assume you have to get the name property and compare.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(2,063 Views)
Highlighted

@Hooovahh wrote:

 

So my question is this, how can I get a reference to a clone VI, from within that clone VI, without explicity passing that reference in, in a safe way?

 


How about implementing a User event in that VI that'll return "This VI", then you dont need to open or close any ref. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 9
(2,054 Views)
Highlighted

Uh I hate multi replies in the NI forums.

 

@jimmy.chretien

I don't hate this idea, but at that point I could just make the subVI have the VI reference input required and force the developer to wire it up, but the intent was to make this function (and others like it) easy to use to where they didn't have to do that, the developer would just plop one of these down and things would just work.  If I went the scripting route I'd probably put it as a Pre-Build VI in the build of the application.

 

@Yamaeda

Like you said the GetRefnumInfo just says what type of reference it is, (a VI Reference) I don't see a way to distinguish between a This reference and a non-This.  Getting the VI Name will return the same for a This as it would the non-This.  You can look at the clone names to see if they differ, but I'm also interested in knowing if I can make this function work for non-clone VIs too.

 

I'm not following the user event method.  What do you mean by that?

0 Kudos
Message 6 of 9
(2,046 Views)
Highlighted

Check out this idea, it should work.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 9
(2,027 Views)

@Hooovahh wrote:

 

If I drop this function on a reentrant VI then things could be a bit hairy.  I can still use the call chain to get the name of the clone VI, and I can still use the Open VI Reference with it.  But according to LabVIEW R&D being able to open a new reference to a clone VI is not something that should work due to possible instability.


It's my impression (unconfirmed) that the issue is that the clone is not held in memory by the created second reference, and if it is removed from memory then using the reference could cause a crash or other failure.  If true, this would mean that a subVI can safely use a reference created from its own call chain, as by definition all those callers are running while the subVI is.  

0 Kudos
Message 8 of 9
(2,006 Views)
Highlighted

@Yamaeda wrote:

Check out this idea, it should work.


This makes my use of the utility VI even more work for the developer.

 

@drjdpowell

I hope you are right and then getting a reference to the clone by the clone name won't cause crashy crash.

0 Kudos
Message 9 of 9
(1,973 Views)