BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code


@altenbach wrote:

So somebody posts some convoluted code, I post a reply with a simple demo 1/4 the size of a postcard, but the OP considers it "really complicated" and  creates the following much simpler (NOT!) implementation instead, spanning three screens and basically violating every single rule for event structures and sane coding practices.

 

How does one respond to that? 😄 Sigh!

 


 The only thing missing is another event case in a case structure, he did everything else 😄

0 Kudos
Message 2301 of 2,560
(6,176 Views)

Hmmm, so what's the difference? (See this thread)

 

 

altenbach_0-1625238456697.png

 

0 Kudos
Message 2302 of 2,560
(6,071 Views)

 (found in here. )

Some random code fragments (At the top as implemented and equivalent alternatives below). 

 

altenbach_0-1626013845090.png

 

 

The toplevel VIs are a scary nightmare, covering 40 screens and with all UI interactions done 100% via value property nodes of controls inside disconnected clusters.

 

(Here is a small section. Not much difference anywhere else on that diagram)

 

 

altenbach_0-1626013622918.png

 

 

 

 

 

Message 2303 of 2,560
(5,915 Views)

Here's a very simple diagram comment explaining that the code will "exit the loop" when an error occurs.

 

Makes sense? No!

 

altenbach_1-1626533657061.png

 

 

Let me be very clear, the stop function does not exit the loop, it will abort the entire VI and its hierarchy!

 

(Yes, there are real ways to exit a FOR loop early, e.g. by showing the conditional terminal)

 

(found here)

 

0 Kudos
Message 2304 of 2,560
(5,743 Views)

rgc.png

The subVI takes an array of parameter names and outputs a corresponding array of parameter values.

This code will only work if the order of elements in the string array matches the order of the enum constants and they both match the order of items in the enum typedef.  Of course the proper code would be:

nrgc.png

I just not sure how I can go about edifying my cow-orkers.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2305 of 2,560
(5,507 Views)

James_W_0-1627391995350.png

Would this resolve the issue of enum order (and allow for some error handling Paul?)
We were after a Rube solution weren't we? 😜

edit:
Of course it might just be simpler to pass an indexed string output of the FOR loop (Format into string) into the subVI thereby using the Enum and eliminating the Rube!😂

James_W_0-1627392632989.png

Much more edifying for everyone - use of Enums is good, prevents Typos in Strings and updates when type def gets updated.

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 2306 of 2,560
(5,438 Views)

@paul_cardinale wrote:

edifying


Nice word I didn't know, btw 

0 Kudos
Message 2307 of 2,560
(5,435 Views)

@James_W wrote:

James_W_0-1627391995350.png

Would this resolve the issue of enum order (and allow for some error handling Paul?)
We were after a Rube solution weren't we? 😜

edit:
Of course it might just be simpler to pass an indexed string output of the FOR loop (Format into string) into the subVI thereby using the Enum and eliminating the Rube!😂

James_W_0-1627392632989.png

Much more edifying for everyone - use of Enums is good, prevents Typos in Strings and updates when type def gets updated.


Good Lord!.  Your 1st whack at it is worse than the original crap!  And in your 2nd dump you're building an array from constants instead of just using a constant array!  Did you study under Rube Goldberg?

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2308 of 2,560
(5,200 Views)

Building an array from three scalars is so difficult (seen here)

 

altenbach_0-1627835647671.png

Message 2309 of 2,560
(5,060 Views)

Parsing a serial number into a special format (003B006A -> 0x00, 0x3B, 0x00, 0x6A) takes 1.5 feet of code or can almost fit on a postage stamp. Your pick! 😄

 

(seen here)

 

 

altenbach_0-1628964333172.png

 

If we can assume that the serial number is a hex formatted U32 (maybe we can!), many other solutions are possible, e.g.:

 

altenbach_2-1628965745667.png

 

 

 

(Still, it is probably more efficient to stay with strings as in the first example)

 

 

 

Message 2310 of 2,560
(4,228 Views)