NI Home > Community > NI Discussion Forums

BreakPoint

Showing results for 
Search instead for 
Do you mean 
Reply
Knight of NI
altenbach
Posts: 27,068

Re: Fun with array initializations



Ben wrote:
Now I have not checked recently but in LV 5 or there-abouts, the top input of the math operators was re-used...
I've never seen any difference (speed, memory, buffer allocation, etc.) if you swap the inputs to the multiplication. I think they are equivalent in recent LaVIEW versions.

LabVIEW Champion . Do more with less code and in less time .

Knight of NI
RavensFan
Posts: 15,681

Unnecessary Operations

In here there are several unnecessary operations.
 
1.  Let's take a number and subtract zero.
2.  Let's feed the size of the array into the for loop and also autoindex it.
3.  Let's step through an array of clusters, then unbundle and rebundle each one.
Active Participant
Posts: 255
0 Kudos

Re: Unnecessary Operations

[ Edited ]
I get a chuckle out of this one. I guess it means that To Lower is not commutative.

Message Edited by Odd_Modem on 06-15-2007 05:38 AM

Knight of NI
Posts: 18,064
0 Kudos

Re: Rube Goldberg Code

[ Edited ]
I'm not sure I see what is "Rube Goldberg"-ish about this ("fun with caps" example). It seems more like an experiment to see what the behavior of those functions is with respect to numbers. The experiment makes sense when you see the actual behavior of the functions.

Message Edited by smercurio_fc on 06-15-2007 09:25 AM

Knight of NI
altenbach
Posts: 27,068
0 Kudos

Re: Rube Goldberg Code

It just means that "to upper" and "to lower" both loose information. The "rube-ish" part is the fact that the loop runs for 1023 iterations (why not 1024), while we only have 256 characters. :smileyhappy:

Plot "toUpper-ToLower" vs "ToLower-ToUpper" for some real mess. :smileywink:


LabVIEW Champion . Do more with less code and in less time .

Knight of NI
Posts: 18,064
0 Kudos

Re: Rube Goldberg Code

Yeah, I know. It just doesn't seem very "Rube Goldberg"-ish to me. At least based on the definition you had provided from Wikipedia, and prior examples. A curiosity nonetheless.
Knight of NI
altenbach
Posts: 27,068

Re: Rube Goldberg Code

[ Edited ]
Some easy path operations, the Goldberg way. :smileyvery-happy:
 
As a substitute for a simple file dialog, we can use...
  1. "open file"
  2. convert the refnum to a file name
  3. then close the file.
  4. Why!!!!!!
As a substitute for strip path, we could ...
  1. convert the path to a string
  2. reverse the string
  3. search for "\" (will only work on windows :smileysad:)
  4. get the remaining string
  5. Reverse the remaining string
  6. convert the string back to a path.
  7. Why!!!!!!!

Here are some literal simplifications:

(Of course we could configure the file dialog to select a folder, so we don't even have to strip anything! :smileyhappy:)

(adapted from http://forums.ni.com/ni/board/message?board.id=170&message.id=263204. The actual VI had the code all over the place and not nicely aligned as shown here).

Message Edited by altenbach on 08-03-2007 12:09 AM


LabVIEW Champion . Do more with less code and in less time .

Knight of NI
altenbach
Posts: 27,068

Ways to read a two-column table from a file

[ Edited ]

(Adapted from http://forums.ni.com/ni/board/message?board.id=170&message.id=264879&jump=true)

We need to read a simple two-column file (tabs between elements, linefeeds between rows) and place the first column into an x-array and the second column into a y array.

Lets do the following: We have a file path control that needs to be connected via a right-left wire to read the raw text. Now we first need to parse it into an interleaved array, throwing away the distinction between tab and newline. Of course we need to read 2048 points, no matter how many points are in the file. Since we now have an interleaved array, we need to decimate it again into the two colums. (A simple decimate array node with two terminals would be way too simple, we better use two FOR loops and index out the even and odd elements.

or we could just do the following:

Message Edited by altenbach on 08-11-2007 12:43 PM


LabVIEW Champion . Do more with less code and in less time .

Knight of NI
altenbach
Posts: 27,068

Sequence-itis

[ Edited ]
 
If somebody would try to argue that stacked sequences are not that great, here are "supporting documents" (see comments on image). :smileyhappy:
 
 
Or we could add a lot of functionality (plotting of the best fit, etc.) and still have a much simpler diagram:
 

Message Edited by altenbach on 08-11-2007 01:08 PM


LabVIEW Champion . Do more with less code and in less time .

Knight of NI
Knight of NI
tst
Posts: 10,826

Re: Sequence-itis

These are great. You should just start Alten's weekly fixes or something like that. :smileyvery-happy:

___________________
Try to take over the world!