BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Minutiae (that may bite you someday)

Highlighted

Here are two more classics:

 

Empty Arrays.png

Message Edited by tst on 05.05.2010 06:41 PM

___________________
Try to take over the world!
Message 11 of 131
(7,230 Views)
Highlighted

JackDunaway wrote:

The next bit of minutiae is probably much more well-known to the experienced LabVIEW users, but it is much more common: feeding references through For Loops.

 

ShiftVersusTunnels.png 


 

A big exception are Pictures. Programmers might think that a picture wire is just a reference, while in fact is is just a fancy string. All the image function simply append to the end of the current picture if so wired. (This is quite different to the image toolkit).
 
Here is a classic example:
 
If we think we do things "in place", by keeping the picture in a shift register, we are completely wrong. "Draw unflattened pixmap" simply appends the the existing picture and you'll run out of memory within a couple dozen iterations. Look at the chart ouput!
(Note that the size of the picture itself remains at 500x500 pixels.)
 
 
 
 
 
If we start with an empty picture, the size is constant and manageable.
 
 
Message Edited by altenbach on 05-05-2010 09:01 AM

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Download All
Message 12 of 131
(7,219 Views)
Highlighted

Nice thread idea, JackDunaway

 

Another one: Empty arrays (>=2D) have "ghost" non-empty dimensions that affects operations with other arrays:

 

20100505145430.png

On concatenation, the appended array takes the largest number of columns, which is 10 even if the first aray is empty.

It may be handy when initializing an empty array that must have a minimum column width.



LabVIEW, C'est LabVIEW

Message 13 of 131
(7,177 Views)
Highlighted

The Array to Spreadsheet String looks like a function that plays nicely with others... but maybe not!

 

Checking out the following bit of code, it appears to produce a clean output. Look at the hex display of that string, however:

 

18651iD41FB32391C03030

 

18653iB9F4422D65A20F75

 

Wow, the "1,2,3" looks just fine in the original output, but what's that "0D0A" doing on the hex display?? You got it, read the Help carefully on that function, and you'll realize this primitive gratuitously adds a platform dependent EOL character to the end of the string.

 

So, don't make the same mistake I did (see the next post for the corrected solution) in thinking this function is a shortcut to turning a 1D array into a delimited string.

 

Here's a snippet of the delimiter I use instead:

 

18655i52A60AA8BE4A669F

 

(Homework: this VI may be more efficient with an auto-indexed output run into a final Concatenate....)

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Message 14 of 131
(6,870 Views)
Highlighted

I am just linking to this "riddle" and bit of minutiae... Tab Control "magically" changing value? (a riddle for all to enjoy). If you want to try to solve the problem, only read the original post. Ben has the solution a few replies down the thread.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Message 15 of 131
(6,866 Views)
Highlighted

I like to use Array to Spreadsheet String because it is simple.  I just remove the last two characters (\r, \n) at the end.

 

18657i14BF9416EDE85332

- tbob

Inventor of the WORM Global
0 Kudos
Message 16 of 131
(6,872 Views)
Highlighted

@tbob wrote:

I like to use Array to Spreadsheet String because it is simple.  I just remove the last two characters (\r, \n) at the end.

 

18657i14BF9416EDE85332


Note: NOT robust for porting OS's (are you supposed to remove one byte? two bytes?). I have seen a different flavor that actually removes the number of characters returned by the "End Of Line Character" on the string palette, but at this point the code gets dirtier and more obfuscated than the roll-your-own delimiter.

 

Plus, the roll-your-own version can easily support a Unicode UTF-16 string, whereas the "Array to Spreadsheet String" is stuck in the ASCII realm.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
0 Kudos
Message 17 of 131
(6,867 Views)
Highlighted

 


@tbob wrote:

I like to use Array to Spreadsheet String because it is simple.  I just remove the last two characters (\r, \n) at the end.

 

18657i14BF9416EDE85332


I use the Trim Whitespace on the output.

 

0 Kudos
Message 18 of 131
(6,861 Views)
Highlighted

 


@tbob wrote:

I like to use Array to Spreadsheet String because it is simple.  I just remove the last two characters (\r, \n) at the end.

 

18657i14BF9416EDE85332


I just use the Trim Whitespace.vi found in the string pallet to remove the EOL.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 19 of 131
(6,856 Views)
Highlighted

I never have to port to another OS nor do I ever have to use UNICODE.  So I typically don't think about those things.  But the trim whitespace solution would be the best if you have to worry about those things.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 20 of 131
(6,839 Views)