BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Interesting idea on how to avoid all errors:

 

====>   Wire the "Simple Error Handler" before the function of interest. You'll never get an error 😄

 

 

(Seen here)

Message Edited by altenbach on 10-28-2008 10:28 PM
Message 331 of 2,635
(12,692 Views)

OK, heres a gem from the same post as above:

 

Maybe I completely misunderstanding all this, but apparently the programmer simply wants to know the largest of five integers.

 

Besides the fact that the code is seriously flawed to begin with (and can give incorrect results), does it really need

  1. a diagram constant of "5"! 
  2. a FOR loop!
  3. a case structure!
  4. a shift register with five terminals!
  5. a feedback node! (yes! in addition to the shift register...)
  6. a case structure!
  7. a comparison operation!

 

I would like to see the code if we need to get the largest of 50 integers. 😮

 

Message Edited by altenbach on 10-28-2008 10:52 PM
Message 332 of 2,635
(12,689 Views)

So, we get a key character from an event terminal (as I16) and need to see if it matches a certain key.

 

Simple (as seen here)!

  1. Built it into an array with one element.
  2. Convert to U8
  3. Use "byte array to string" to convert to a string
  4. Compare resulting single character string with the desired string.

(...or we could just compare the Char directly. :D)

 

Message 333 of 2,635
(12,602 Views)
I'd be curious to see if the user does the same thing using the suggestion I had provided to use the Input Device Control function in order to recreate the program in 8.2 without an event structure (since the user has just the base edition of LabVIEW). Smiley Very Happy
Message 334 of 2,635
(12,600 Views)

LOL!!   I needed that laugh.  Good one Saverio.  😄

 

Also excellent posts by Christian..  🙂

0 Kudos
Message 335 of 2,635
(12,591 Views)

altenbach,

 

Do you mean comparing the char directly with the ascii representation (i.. 43 for the "+")?

 

If so, although your suggestion is indeed quicker to execute, does the human factor of looking at the code and seeing what it does not come into it? I mean the "clumsy" code would still execute in a few femtoseconds!

 

I am curious as I have used code like this before!!! (If you can provide a slick way of directly comparing to the "+" character please do show)

0 Kudos
Message 336 of 2,635
(12,544 Views)

nrp wrote:

If so, although your suggestion is indeed quicker to execute, does the human factor of looking at the code and seeing what it does not come into it?


I agree, speed is irrelevant here. The main point is diagram clutter. If you jump through so many hoops, another programmer might not understand why.

 

If you want to support the "human factor", you can start with a "+" string and convert it to the number outside the loop. This only needs to be done once. (see image)

 

(You could also simply show the label of the I16 diagram constant (61) and type e.g. "+ key" as label to make things easier to read.)

Message Edited by altenbach on 11-05-2008 01:18 PM
Download All
Message 337 of 2,635
(12,538 Views)
Message 338 of 2,635
(12,494 Views)

As one who is relatively new to LabView,I found this thread rather... enlightening.

Is there also a thread in which you have shared particularly elegant or clever (in a 

good way) solutions you have come across?   You know, the kind of constructs

that make you say, "Oh!  I wish *I* had thought of that!"

 

Thanks and Best Regards,

-- J.

0 Kudos
Message 339 of 2,635
(12,489 Views)

JeffBuckles wrote:

Is there also a thread in which you have shared particularly elegant or clever (in a 

good way) solutions you have come across?  


 

LabVIEW nuggets perhaps?

0 Kudos
Message 340 of 2,635
(12,486 Views)