Jump to content

Return control reference


Recommended Posts

Hi,

   I would like an object that will return a control's reference when a control is wired into it. If one does not exist I thought there may be a way with VI Scripting to achieve this.

   The called VI ("Return_Reference") could look at the call chain and return all the controls from the calling VI. Would then there be a way to detect which control is wired to the particular clone instance of the called VI?

 

Many thanks, Alec

Link to comment

Yes this could be done with scripting.  Of course if you call the VI in to places on one VI I don't think you'll be able to find one versus the other.  This would have to be done with scripting, so you couldn't do this in a built application.  Also you would probably want to limit this to only work with a control terminal wired directly to the subVI.  For instance if you had a string control, then go to a string concatenate, then to your VI then this function wouldn't work.  It sounds too difficult to keep looking up stream to find a control.

Link to comment

wow, Awesome! Thanks, I'd been all day grappling with this one. Can you get it to return the control reference so that I can access the label name of the control feeding in to it, I can't seem to get it to display any word other than 'value'.

Many thanks for your help thus far!!

(I know its a long shot but it is safe to say there is no way of achieving this without VI Scripting and therefor can not be used with the Runtime enviroment?)

Link to comment

The subVI I made has a connector pane with only 2 terminals.  I did that for simplicity because I didn't know which would be input and output this way I could know index 0 was output, index 1 was input.  Disconnect the variant output from the connector pane, and connect the Control Reference control to it.  I made an indicator in the subVI for the reference itself.

 

EDIT:  And yeah I can't think of anyway to do this without scripting.  Besides this needs the block diagram to be available and EXEs generally strip those out.

Link to comment

Hi, Please could you help me upload some code, I am trying to show you what I mean, I need to programatically determine which is the control I want.

 

I am attempting to:

  • Wire a numeric into a sub VI, and for that sub VI to return the reference of the wired VI (including its label)
  • The Sub VI is looking at the call chain and indexing value 1 out and opening a reference.
  • I am then looking at all of the controls on the calling VI
  • For each control I am looking at the wire coming out of it and seeing if any one of them is going into an input labeled the same as the input on the sub VI.
  • Then I am trying to take that reference to the sub VI on the other end of the control's wire and cast it down to a VI type (this goes wrong)
  • Then I wish to take the "Clone Instance" name, and match it to the currently runnning clone instance in memory to see if we have a winner

As I mentioned, I am struggling with casing down to VI type, any idea why? (or how to attach a .zip file to this message)?


Many thanks, Alec

Link to comment

I'm not sure I fully understand the problem.  Is there something wrong with the VIs I posted other then the output of the subVI should be the reference instead of the value?  Is the issue that you want to do this for multiple VIs at once?  That will get tricky.  I'm not sure how a subVI can know which instance on another VI it is responsible for.

 

Feel free to attach a zip.  You'll need to click More Reply Options, and from there can attach files.

Link to comment

Hi,

   I have got this vi to work now for a single instance, but I can not get it working for multiple instances (see attached) When I use the constant "This VI" inside a clone instance, does it not return a unique reference depending on the clone instance? As you can see from this example I do not think that it does, and the VI Server Subclass GObject.Node.SubVI does not seem to contain any kind of 'clone' information. Any Ideas?

Many thanks, Alec

Refnum Obtainer.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.