01-05-2015 03:36 PM
I recently spent too much time looking for an error in code "that used to work". So I asked a student to look over my shoulder while I explained what was supposed to happen. The bug is illustrated in this snippet:
I'm doing a simple Bundle by Name, using a pre-defined TypeDef to define the cluster. What I expected to get is shown on the left, and what I actually got is shown on the right. The code looks the same, but the result is very different!
My student innocently asked if I was seeing, in fact, the Default value of my TypeDef (answer -- Yes). He then asked if I had wired the TypeDef to the output terminal "by mistake". This turns out to be almost right -- what I'd done was to wire the Indicator, not to the Output Terminal, but, in error, to the Input Terminal.
Notice the two beige rectangles at the right edge of the Bundle by Name. The right-most is the Output, the left-most is the Input (which is where the TypeDef wire comes in). What I'd carelessly done was to drag a wire from the Indicator "far enough" to make a connection, but, in fact, I dragged it too far so that it entered the Input rectangle. Here are close-ups of the Correct and Wrong wires with highlighting -- it isn't easy to see, but the highlighting on the Wrong wire extends into the left-most beige rectangle. If you bring your pointer in very carefully to the junction, you can sometimes see a Coercion dot on the edge of the Bundle function, but I couldn't capture it.
Needless to say, this behavior, the ability to "mis-wire" a Bundle-by-Name function, was quite unexpected (by me) -- I spent most of my time suspecting subtle errors in my code and logic, not errors in wiring!
You can bet that I checked other places where Bundle by Name occurs in my code. I'm posting this here in hopes that others do not fall into the same trap.
Bob (embarrassed) Schor
Solved! Go to Solution.
01-05-2015 04:00 PM
I checked your snippets and they are both wired correctly. If you are daring, you can use autocleanup to make this sort of thing more obvious. There's also been some idea exchange ideas to make issues like these (hidden wires) into hard "break run arrow" errors optionally.
01-05-2015 04:02 PM
Been there, done that. I learned very early on to clean up my wires connected to the bundle by name just to make sure the wiring was correct for that reason. (I'd then lay them out how I wanted them to look.) Sometimes I can be a bit shaky with the mouse and wires get connected to the wrong place.
01-05-2015 04:41 PM
Son of a gun -- you are right, creating a Snippet either fixed the error, or when you paste the Snippet into LabVIEW, it "does what you mean", not "what you say".
If you try this "by hand" and deliberately bring the wire from the indicator to the left connector rectangle, you should duplicate my error.
BS
01-06-2015 02:13 AM
I doubt the snippet auto-corrected the mistake. Most likely you accidentally snapped a correct version of the code.
In any case, I was wondering why it was that I never noticed this, so I had a look and now I'm going to guess that you have the auto-routing option unchecked. If it is checked, then LV automatically moves the wire to the top when you hover over the input terminal, thus not causing the issue you saw. I'm 99.9% sure that auto-routing is enabled by default, so the majority of people will never run into this.
01-06-2015 11:50 AM
You are absolutely correct -- I hate auto-routing of wires, as I think "my way is neater". [Hmm, a little OCD here?]. Live and learn!
BS
01-07-2015 08:14 AM
Sorry to beat a Dead Horse, but I wanted to bring some closure to this topic, and to comment on some of the helpful Replies. A revised version of the Snippet is also included, below.
I hope I remember these lessons six months from now ...
Bob Schor
01-07-2015 08:34 AM
I expect that this won't make you change your habits, but it should probably be pointed out that the auto-routing behavior can be somewhat overridden -
As for "Hebrew wiring", it's the main language I grew up speaking and I use it every day (including in LV), but I almost always start wiring from the source, not from the sink, so I can say that at least that mindset is not a direct influence. Maybe it is the "ambidextrous" mindset.