LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (10/28/2009) - Write Text to File

One of the areas of the palettes that has changed significantly through the years is the File I/O portion.  We used to have to sift through Write to IThis or IThat or Whatever.  Now we have today's function "Write Text to File" and its cousin "Write to Binary File".  Many times I use the binary version, even for text, but there is one feature of Write Text to File that I like and use now and then.  Let's say you are generating an array of strings and you would like to output the results to a text file.  There are many ways to do this, here are a few I thought of this morning.

 

WriteToTextFile.png 

 

I have never done the hard way, but it is what would go on in Write To Spreadsheet File if it accepted strings.  I started out with the slightly ugly way and eventually used the concatenate strings method once I had read the help.  Then I discovered that Write Text to File will accept 1D arrays, and now there is no going back.  My only complaint about the function as-is is the use of an unwired terminal to trigger a dialog.  I have to place a second VI which checks for an empty path (my usual signal) to trigger a file dialog and always pass a refnum to this VI.  I wish I knew exactly what the consideration was for this choice (performance, likely error condition) so I could weigh it against the cost of the extra subVI.

 

VIOTD groundrules here.  

Message 1 of 4
(3,025 Views)

Darin.K wrote:

 

I have never done the hard way, but it is what would go on in Write To Spreadsheet File if it accepted strings.  


Write to Spreadsheet File does accept strings.  At least in the more recent versions of LabVIEW.

Message 2 of 4
(3,009 Views)

Good old polymorphism.  Still the same dirty work, just letting someone else do it.

 

And that happens to be the exact reason for this exercise: I get stuck in my old habits and by forcing myself to reexplore areas I thought I knew, I learn something.  Although, my goal is to learn one new thing each day,  I am getting dangerously close to far exceeding that amount.

Message Edited by Darin.K on 10-28-2009 09:58 AM
Message Edited by Darin.K on 10-28-2009 09:58 AM
0 Kudos
Message 3 of 4
(3,003 Views)

Darin.K wrote:

 

Although, my goal is to learn one new thing each day,  I am getting dangerously close to far exceeding that amount.


 Then you better stop and tell your boss you need to go home for the day.Smiley Very Happy

0 Kudos
Message 4 of 4
(2,982 Views)