11-10-2008 03:29 PM
I have been having trouble the last couple of days trying to correctly pass a value into a subVI. The subVI reads the control from within a while loop. The subVI was set up like this because it was a standalone program that reads a new value from the control each time the loop interates. When this program is used as a subVI, the default value from the control is read each time, regardless of what the input was. The only way I have been able to fix this is to move the control outside of the while loop.
This solution is not an option without further modifications of the original VI, which I prefer not to do because I would be forced to use property nodes. In particular, a new hidden control would be used to set the value of the original control in the init case of the state machine (inside the loop) with a property node.
Is there something that I'm not seeing, maybe a way of setting up the call to the subVI?
11-10-2008 03:36 PM
astromike wrote:Is there something that I'm not seeing, maybe a way of setting up the call to the subVI?
There is a lot that I am not seeing, simply because your description is not very clear.
Is the while loop in the subVI, in the calling VI, or both?
Where exactly did you move to control to fix the issue?
How are the connectors of the subVI setup?
Could you attach a simplified example that shows the problem and the general program layout?
11-10-2008 04:01 PM
Here's an example of what I was trying to say. It is a dumbed down version, but for some reason, the dumbed down version works. Looks like I've got more to look through.
11-10-2008 04:15 PM
It is a really bad idea to have multiple controls and indicators with the same name. Could it be the value property node links to the wrong terminal with the same name? (50% chance!).
Since this example actually works for both inputs, maybe you should show us your real VI instead. 🙂
11-10-2008 04:24 PM
11-11-2008 09:33 AM - edited 11-11-2008 09:34 AM
I found the problem after further looking at the application I was turning into a subVI. The subVI had a call to the Reinit Controls VI with a true constant wired to reinit all. The error output of this method was wired to the input of the while loop. It appeared to work when the control was out of the while loop on shear luck as a race condition existed between reinitializing the controls and reading the controls. When the control was in the loop, the while loop required the Reinit Controls to be run before entering, so it was guaranteed that I would not have the values I passed in. I have updated subVI.vi with this for furhter illustration.
Thank you for at least trying to resolve the issue on what was given.