From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-05-2019 03:31 PM
Happen to run across this page, comparing C and LabVIEW code for a simple sorting task..
Obviously, it's old (e.g. from the look of local variables and boolean constants) and obviously the authors tried to synchronize the code to more faithfully resemble the C code, which is typically a bad idea. 😄
A real LabVIEW programmer would immediately:
(Of course the second version of bubble sort further down could be implemented with an IPE for cleaner code, but that did not exist(?) back then...)
12-09-2019 08:58 AM
Quoting still not an option...
Christian!
The Seq is required to ensure the value is placed in the indicator BEFORE the loop starts.
That code shows how we had to do things BEFORE the Event Structure existed.
Ben
12-09-2019 09:40 AM
@Ben wrote:The Seq is required to ensure the value is placed in the indicator BEFORE the loop starts.
That code shows how we had to do things BEFORE the Event Structure existed.
But if you change to use a Shift Register instead, the control/indicator is not even needed. I once inherited similar code and I reduced execution time to a small fraction just by eliminating local variables by using a shift register instead.
12-09-2019 11:14 AM
@Ben wrote:
The Seq is required to ensure the value is placed in the indicator BEFORE the loop starts.
That why I said "it is no longer needed" because we already added a shift register in step #1 and now we just initialize it with the array. 😄
12-13-2019 11:05 AM
There are many (many!!!) things wrong with this code (Even Darin's patched version fills about 200 screens!).
But let's have a look what we would need to do if "boolean array to number" never existed (Yes, this is only a small section. It goes on forever with many (many!) more instances):
Similarly, how many times do we need to read the same values via local variables in parallel?
This thing is straight out of the twilight zone. Who would ever program like that???
The entire code could probably be reduced to one screen, even a postcard!!
12-14-2019 03:32 AM - edited 12-14-2019 03:32 AM
@altenbach wrote:
This thing is straight out of the twilight zone. Who would ever program like that???
The only excusable situation (pretty sure that's not what happened here) is when scripting was used to generate the code from a (text\excel) script. The 'beauty' of such a tool is that if it works for small scripts, it will simply gets bigger for large scripts. Until it gets too big (extending diagram limits).
Even then, I'd change the scripting to produce something more decent.
12-15-2019 12:23 PM
Stumbled across this old thread (2010), and it seemed difficult to imagine that calculating the angle between two lines would really need three linear algebra and one trigonometric function (top of image).
As a public service announcement, here's how to get the same result using (simple!) complex math (bottom of image). 😄
12-18-2019 02:18 PM
@altenbach wrote:
There are many (many!!!) things wrong with this code (Even Darin's patched version fills about 200 screens!).
But let's have a look what we would need to do if "boolean array to number" never existed (Yes, this is only a small section. It goes on forever with many (many!) more instances):
The worst part about that is that the developer clearly knew "Number to Boolean Array" existed as it was used elsewhere in the code.
Side note, I can't even imagine how someone would develop and debug a VI like this.
"Oh, there's a bug. I think that section of code I need to move my horizontal scrollbar about 82% to the right, vertical about 24% down, and then go to that stacked sequence structure and select sequence 28"
I can only imagine that VI took months to develop. Looking at what it actually does, I would expect a couple weeks at most.
12-19-2019 07:52 AM
BewenM wrote;
"
I need to move my horizontal scrollbar about 82% to the right, vertical about 24% down,
"
I have had to support code like that!
The customer added letters across the top and numbers down the side so he could say "go to F7".
Ben
12-19-2019 09:54 AM
@Ben wrote:
BewenM wrote;
"I need to move my horizontal scrollbar about 82% to the right, vertical about 24% down,"
Coloring the diagrams should work really well combined with the navigation window.
Simply make high risk zones red, followed by orange, yellow and green. If there's a bug, navigate to the red zones, and work you're way down!
(/S, if that isn't obvious.)
@Ben wrote:
The customer added letters across the top and numbers down the side so he could say "go to F7".
Those label arrows work nice for that. Place them outside all the structures, and point the label arrows inside. Double click the line of the arrow to go to the code. That works nicely as bookmarks (but faster than actual bookmarks).
I actually did this a few times. Works wonders in state machines. But I usually delete them when moving to the next issue.
Don't tell that to whoever needs tricks like this, it might be misinterpreted as encouragement.