BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

To get two columns from a 2D array we could (seen here)

 

  1. transpose the array
  2. get the second row (was second column before the transpose)
  3. measure the size of the second row (i.e. the size of the original first column)
  4. reshape the entire 2D array to a 1D array with the same size as the second row to get the first row, (which originally was the first column).

 

.... or we could just get the two columns directly (note the zero wired to the lower index). 😄

 

 

altenbach_0-1659734756923.png

 

 

Message 2431 of 2,635
(2,670 Views)

Famous last words, completely redefining the word "simple" (seen here😞

 

"Hi, I'm working on a simple code with bunch of flat sequence structures and for loops."

0 Kudos
Message 2432 of 2,635
(2,591 Views)

wiebe@CARYA wrote::

Goto is a syntactically correct statement in C++...

 

Probably the fastest way to getting fired if you use it, but still: syntactically correct.


It's the Local Variable of C/C++, it's easy to abuse but have it's uses. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2433 of 2,635
(2,504 Views)

@Yamaeda wrote:


It's the Local Variable of C/C++, it's easy to abuse but have it's uses. 🙂


Did you mean to say Global Variable? Use of locale variables in LabVIEW is definitely a valid use scenario when programming more complex UIs.

As to goto in C, yes it is a bad fellow to use, but I have done so myself quite a few times. Without structured exception handling it is the next best thing for error handling if you do not want to have deeply indented code. Of course one counter argument could be that once you end up having more than 3 or so indentions, you should probably have refactored the code into sub functions.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2434 of 2,635
(2,498 Views)

Here is a code by an intern with many Rude Goldberg, for instance, the following cast structure implementation is just to get a subset of the DDT wires

santo_13_0-1661968557346.png

 

Seen here - https://forums.ni.com/t5/LabVIEW/error-209836-shows-after-program-runs-for-12-hours/td-p/4252717

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2435 of 2,635
(2,342 Views)

@santo_13 wrote:

Here is a code by an intern with many Rude Goldberg, for instance, the following cast structure implementation is just to get a subset of the DDT wires


And the double wired to a case selector is bad enough by itself...

0 Kudos
Message 2436 of 2,635
(2,306 Views)
I feel bad for that intern. He was given a difficult task (for a newbie to LabVIEW) in something he wasn't trained to do with virtually no oversight and given an extremely tight deadline to do it. The fact he got as far as he did given the circumstances is impressive. Not only that, his post is courteous and shows that he's already learned a bunch from the start of the project but just doesn't have time to refactor his code.
Message 2437 of 2,635
(2,270 Views)

@BowenM wrote:
I feel bad for that intern. He was given a difficult task (for a newbie to LabVIEW) in something he wasn't trained to do with virtually no oversight and given an extremely tight deadline to do it. The fact he got as far as he did given the circumstances is impressive. Not only that, his post is courteous and shows that he's already learned a bunch from the start of the project but just doesn't have time to refactor his code.

It is indeed impressive for an intern to develop something that large without any formal training.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2438 of 2,635
(2,234 Views)

The IPE (index array) is of course useful if you care about the existing value. If we don't care about the existing value, it's just a glorified "replace array subset". 😄 (seen here)

 

altenbach_0-1663525165757.png

(Yes, that entire thread is weird in general, trying to solve a very poorly defined problem)

Message 2439 of 2,635
(1,998 Views)

So the simple task is to build xy data for an xy graph in a loop, one point at a time.

 

(seen here)

 

Apparently, we need:

  • four height=1 "built array" nodes
  • two "insert into array" nodes. (Yes, they are actually wired correctly. No way to tell from the picture that the wires are actually crossed behind the primitive!!!)
  • two shift registers
  • two "array size" nodes (they will both always show the same value)
  • a bundle node
  • etc.

Seems a bit much! I have the nagging feeling that it could be simplified. 😄

 

altenbach_0-1663865751116.png

 

Message 2440 of 2,635
(1,921 Views)