07-13-2019 08:44 AM
I have created a simple demo, see enclosed file. I have numeric control connected to scroll bar. From the numeric control is controlled scroll bar and vice versa. If I connect second numeric control (Numeric 2) to scroll bar, I see the value of scroll bar, but from Numeric 2, I cannot control scroll bar and Numeric 1.
Please help advice, where is mistake?
07-13-2019 10:00 AM
You are forgetting (or haven't learned) the most important LabVIEW concept, the Principle of Data Flow. Among other things, it says that a Structure (such as a While Loop) can't finish executing until everything inside it has executed. Your While Loop contains an Event Structure, which doesn't execute until an Event occurs. The only thing that makes this Event Structure "fire" is changing Numeric (an extremely "sloppy" name to choose -- always give your Variables meaningful names, don't be lazy and accept the default).
Try this -- create an Indicator, call it "Value of Num 2", and wire it to the Numeric 2 control. It should "track" Numeric 2, right? Run your code. When you change Numeric, everything else (including Value of Num 2) changes. But when you change Numeric 2, Value of Num 2 remains the same. Do you know why? Remember the Principle of Data Flow, and ask yourself "When did Value of Num 2 get set, particularly in relationship to when Numeric 2 changed".
Bob Schor
07-13-2019 01:42 PM
Bob, thank you.
07-13-2019 11:31 PM - edited 07-13-2019 11:33 PM
In addition to what Bob already said:
Here's a quick modification that hopefully gives you some ideas. I took the terminals outside the loop because we only read the value from the event data node. In more complicated code, place them where they are used.
There is no need to micromanage which control has changed and what needs to be updated using tons of complicated code. Just write back to all. Also note that since a scrollbar can generate many value changes as it is operated, I limited the event queue to 1.