05-25-2009 12:02 PM
Coq rouge wrote:But using a Matlab script node is more elegant
If you follow the input wires to the source, you'll notice that it starts out as a plain 2D array, which is then converted to dynamic data, split into two, each half forming one of the two inputs to the matlab script node where the are coerced to a scalar. So basically it operates on a 2D array to get a simple scalar, but takes the detour via antarctica and the dark side of the moon. 😄
I also wonder what the idea was for the second line in the script. Why not drop it and call the output IL2?
I am not good at predicting outcomes when dynamic data is involved, because we cannot see the actual configuration of "to dynamic", but I have a suspicion that the entire mega-operation could be replaced with about two simple primitives (e.g. index array, array subset, add array elements, or similar)
06-04-2009 08:48 AM
If found some realy nightmare code here http://forums.ni.com/ni/board/message?board.id=170&thread.id=413574 today. I took one look and decided. NO this one is not for me 😉
Link to code here http://forums.ni.com/ni/attachments/ni/170/413957/1/Zaj-traj-14.04.09-DAQmx-02-7.0.zip. It is far to big to show in a picture. But I warn you it is horrifying
06-04-2009 09:58 AM
Oh my. That code could also be posted on the forums for why locals are bad or even under sequencitis.
I think the navigation window is a bad thing, but it's almost necessary with this VI.
I don't think that I have enough time available to look through that code to help.
Rob
06-04-2009 10:51 AM
06-04-2009 11:06 AM
Coq rouge wrote:If found some realy nightmare code
Ouch!
This is one of the few cases where we need the navigagion window for the front panel. 😄 All that garbage outside the view is the graveyard of local variables.
I like how frame 4 of the big sequence is fully optimized for a 40x core CPU. 😄
06-05-2009 07:33 AM
Coq rouge wrote:If found some realy nightmare code...
Wow!
So for fun I did the replace with flat sequence fllowed by a diagram clean-up. To try and get a handle on how large the resulting diagram was I used a decoration on the diagram to (try and ) suround the code so i could use the size box to tell me how big it was.
What I learned.
1) The flat box decoration in LV 8.6 has a max size of (only) 16,000 pixels wide (what was NI thinking when they limited it to only 16K pixels?).
2) Using two flat sequences I estimated the diagram to be more than 24,000 pixels wide.
After the clean-up the code could be "maintained" but I would not enjoy it (or be comfortable doing so).
Nice (ahem cough, cough) find Coq rouge!
I think I will have to write some LVOOP code today to counter the effect of seeing that VI.
Ben
06-05-2009 09:07 AM
Holy spaghetti batman!
This is why you ALWAYS write notes before code. I am amazed that the code ever worked or did it?
06-08-2009 09:54 AM - edited 06-08-2009 09:58 AM
Let's say I have dates saved as a string. Rather than convert them to dates and compare with the In range and coerce function, let's do some string manipulation and multiple compares to compare as strings. And throw in some unneeded local variables and a sequence structure for good measure.
http://forums.ni.com/ni/board/message?board.id=170&message.id=414671
Let's do this.
Even though this is simpler, makes more sense, and you can trust it to work.
06-13-2009 04:44 AM - edited 06-13-2009 04:46 AM
Once in a while the programmer needs to pad a string with multiple spaces. Unfortunately, the palette only contains a single space constant. Thus we need to be a bit creative and just line up a few of those.
I strongly believe that the palette should also contain a constant with two spaces, one with three spaces, one with four spaces, etc. etc.
(Wouldn't that be something for the Idea Exchange?!! 🐵
Since we are currently limited to a single space constants, we need to resort to complicated code as follows: 😄
(see here)
06-13-2009 08:17 PM
Why wouldnt you just append a constant of " "?
Well, I guess thats more colorful.