01-10-2014 11:57 PM
I am playing with the template where an event structure takes note of user inputs and a main state machine is then used to respond to these inputs. When I only monitor one control I use the 'NewVal' output to read out the changed value. But when I monitor multiple objects with a single case I also have to associate the readout with the correct owner. After some tinkering I was able to extract the label property and use a case to assign them. Are there better ways of doing this? For example maybe there is a way to connect the label text directly to the 'bundle by name'?
Also this should be easy to accomplish by simply creating local variables of the objects and read from them, but I got the impression that the use of global and local variables is now strongly discouraged?
Thanks for any suggestions!
01-11-2014 12:55 AM
Often you can just place all the control terminals inside the event case and just re-bundle all of them (in your case), changed or not. Since a user interaction is always the time limiting step, this won't cause any performance issues. It also keeps the code much simpler and easier to maintain.
01-11-2014 02:05 AM
Let me rephrase my question: say I have placed a group of distinguishable but otherwise identical controls (e.g. 8 switches) in a single case of a event structure and monitor 'Value Change', when a value change does occur, what's the right/easiest way for me to single out the 1 out of all controls being monitored for further manipulation?
01-11-2014 02:27 AM
Christian,
You suggest the terminals be place inside the event case, however they are parameters that need to be initialized in the Initialization process and a user sets the initial values there and later are allowd to make realtime adjustments, so the terminals have to be put in the Initializations step I think...
Jay
01-11-2014 03:56 AM
@jplaserguy wrote:
... so the terminals have to be put in the Initializations step I think...
why?
01-11-2014 10:40 AM
The reason is for me to imitate this standard state machine frame work. I suppose if I put the terminals outside of the event structure, or even outside of the while loop out of the event structure then I can read and write them anywhere I want. But the example seems to suggest all parameters be passed around with the cluster ribbon and nothing else.
01-11-2014 11:46 AM
Well, I don't really like these theroretical discussions. Can you attach a simplified version of some of your code?
There are many other ways to identify the particular control. You could for example search an array of references for the value of the "ctlref" event data node. This would make the code much more robust (your code will fail for example if you (or some other programmer updating your code in a few years!) notices a mispelling and edits the label without also changing the case structure cases).
01-11-2014 02:37 PM
Thanks for the advice! I will post some snippets soon.
Jay