alecjcook Posted June 10, 2014 Report Share Posted June 10, 2014 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 Quote Link to comment
hooovahh Posted June 10, 2014 Report Share Posted June 10, 2014 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. Quote Link to comment
hooovahh Posted June 10, 2014 Report Share Posted June 10, 2014 Okay a couple quick VIs later I have a working version but there are likely better ways to do it. Run Main VI with a control connected to the input terminal. The output is a variant value of that control, getting the value by reference, by looking at the control connected to it. Get Control Ref Test.zip Quote Link to comment
alecjcook Posted June 10, 2014 Author Report Share Posted June 10, 2014 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?) Quote Link to comment
hooovahh Posted June 10, 2014 Report Share Posted June 10, 2014 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. Quote Link to comment
alecjcook Posted June 10, 2014 Author Report Share Posted June 10, 2014 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 Quote Link to comment
hooovahh Posted June 10, 2014 Report Share Posted June 10, 2014 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. Quote Link to comment
alecjcook Posted June 11, 2014 Author Report Share Posted June 11, 2014 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.