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.

BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

An intriguing example shows how to get the dimension sizes of a 2D array was apparenty posted long ago here. (Publish date is in 2013, but there is a comment from 2006, so who knows how old this is. Maybe in LabVIEW 1.0, getting the size of a 2D array was more difficult than today?)

 

  • Why is the [i] terminal hidden?
  • What is the point of the while loop, it only iterates once (unless the 2D size is very large and the sum adds up to a negative value due to I32 wrapping. Then it will never stop, ever!)
  • result is correct for typical inputs (except for above point)

So, what thought process could have possibly led to this code? Mind boggling!

 

(Natural is ""array size" but there is also "Matrix size" that could be used).

 

 

Message 1771 of 2,571
(10,146 Views)

Wow.  That takes a special kind of twisted thinking to come up with that!  And they set up the connector panel to have an input at the top and the outputs at the bottom.

 

Looks like it was saved with LV 7.0, so that is no older than about 2003.  (Well I guess it could be older and they upconverted it to 7.0 sometime around 2003 or later.)

 

I see it links to an NI Example program page that implies that it is somehow NI sanctioned.  I don't know how easy it is to discover that page, but pure garbage like that should be thrown away.

0 Kudos
Message 1772 of 2,571
(10,086 Views)

I'm not entirely sure that I understand that code.


"Should be" isn't "Is" -Jay
0 Kudos
Message 1773 of 2,571
(10,078 Views)

@JÞB wrote:

I'm not entirely sure that I understand that code.


Well, the autoindexing of the plain and transposed array is used to get a column or row, respectively, which then allows getting the row and column 1D size before the loop stops after one iteration. A TRUE wired to the termination would have worked equally well and would have protected from the possible size wrapping of the sum to a negative value.

0 Kudos
Message 1774 of 2,571
(10,064 Views)

I am revising some of my older projects, and I have found this... actually I did not change that much, I am still very vulnerable to end up with Rube Goldbergs 🙂

 

revising1.png

Message 1775 of 2,571
(10,047 Views)

You probably want the Ceil(Index of threshhold) for Start and Floor(Index of threshhold) for end to be an exact dup of the code above


"Should be" isn't "Is" -Jay
0 Kudos
Message 1776 of 2,571
(10,013 Views)

@JÞB wrote:

You probably want the Ceil(Index of threshhold) for Start and Floor(Index of threshhold) for end to be an exact dup of the code above


Yes, thanks.

0 Kudos
Message 1777 of 2,571
(10,011 Views)

I found this code in a review, the idea of the original code was to build the complement of two from a number of bits less than 16. The programmer did it in a really hard and not modular way.  Im not shure if it works for every value...

Build two's complement

Probably there is even a more simpler solution...

_______________
Automate LabVIEW builds easy with Jenkins Plugin www.kubes.ch/Jenkins
0 Kudos
Message 1778 of 2,571
(9,928 Views)

I don't think the two code fragments are equivalent, because the lower code depends on a size input, while the upper does not.

0 Kudos
Message 1779 of 2,571
(9,895 Views)

There's a constant size 14 in the upper one.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 1780 of 2,571
(9,773 Views)