BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

I guess some people want to create complicated, but yet amusing, Rube Goldberg machines (or code in this case).
0 Kudos
Message 671 of 2,635
(11,984 Views)

Just a slight variation on the previous subject.

 

Let's index an array to get an element, build that element into a 1 element 1-D array, then replace that element with itself.

Also local abuse, and doing a + 1 and -1 when increment and decrement should work.  No idea why it is in a simulation loop.

 

Seen here.  If this is somehow legitimate code, please let me know.

 

Message Edited by Ravens Fan on 04-21-2010 09:02 PM
0 Kudos
Message 672 of 2,635
(11,949 Views)

Instead of just using an array, let's insert it into an empty array.  Seen here.

 

Message Edited by Ravens Fan on 04-27-2010 03:43 PM
0 Kudos
Message 673 of 2,635
(11,862 Views)

This is my code for helping someone who wanted to split a string and make it multiple lines if it had more characters than would fit in a column width on a multi column listbox. I'm not positive it's rube, but I'm assuming it so I'm just going to post it and let you all have at it!

 

Message Edited by for(imstuck) on 04-27-2010 05:32 PM
0 Kudos
Message 674 of 2,635
(11,840 Views)

for(imstuck) wrote:

... I'm not positive it's rube, but I'm assuming it so I'm just going to post it and let you all have at it!


 

 
 It's not particularly Ruby, but it is certainly not very robust. For instance, a static 10 characters of "i"s on a line will take up many fewer pixels than a line of "W"s. Try this method: write your string to a string indicator, then play around with the "Get Nth Line" method for the String Class. The beauty of this function is that you can set the font and box size of the string, and the lines are inserted for you at the correct breaks as long as "Wrap Text" is checked on the string indicator. Dynamically set via property node the string dummy's font and container size the same as that of each cell in the MCL. 
 
GetNthLine.png 
Message 675 of 2,635
(11,837 Views)
There is a function in the picture function palette under graphics and sound called "Get Text Rect" that could be useful in determining how large the words are.
Message 676 of 2,635
(11,846 Views)

To wait a minimum amount of time one must not use the Wait function, because, after all, it's not designed to errrr... wait. No, we need to use a while loop:

 

Message 677 of 2,635
(11,799 Views)

Looks to me like more of a quarter-second CPU warmer. (What's ironic here, to throttle the loop you NEED a Wait primitive...) And just to give the original author the benefit of the doubt, maybe it's to make room for future expansion (notice loop size) using more termination conditions. (That seems pretty optimistic...)

 

 

 

 

Message Edited by JackDunaway on 04-28-2010 01:29 PM
Message 678 of 2,635
(11,794 Views)

Um, I have no idea where my mind was the day I did this. But, I am so incredibly guilty of a rube here it's almost comical. And yes, I could use 256 when doing the subtraction, but I wanted to keep everything U8 ints.

 

Message Edited by for(imstuck) on 05-03-2010 05:20 PM
Message 679 of 2,635
(11,666 Views)

Both a small Rube Goldberg and Localitis:

found here http://forums.ni.com/ni/board/message?board.id=170&message.id=495992#M495992

 

 

Message Edited by Ray.R on 05-04-2010 08:42 AM
Message 680 of 2,635
(11,609 Views)