LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display entire text file w/ tabs intact

My vi records data in a tab-delimited format (with headers). I would like to make the text file appear on the screen when execution completes.

One option is to launch an external viewer such as Wordpad or Notepad: how is this done?

Another option (that I have attempted) is to write a subvi that gets the whole file using "Read Characters From File.vi" with "-1" argument for "number of characters" and displays the entire thing in a string indicator. However, this latter approach somehow converts all tab characters to spaces, destroying the column alignment. How can I do this with tabs intact? Is the problem in the file reading or in the string indicator?
0 Kudos
Message 1 of 16
(4,237 Views)
String indicators don't "convert tabs to spaces", they just display them the same because there is no way to set tab positions in string indicators (set the indicator to display "\codes", to see that tab (\t)characters are still there).

An alternative would be to use a "table" indicator. Color the grid lines with the background color if you don't want to see them. You just need a little code to turn your string into a 2D array of strings.
Message 2 of 16
(4,237 Views)
One thing you could do is use the report generation VI's included with labview and have it show as an html report in a different browser. See Examples in labview for that. Another thing you could do is use Active X. I am sending you a lot of VI's that I got from a bunch of different post here and by doing some web searches on active X. These show you how to use word, excel, access, one of them is a toolkit I got for free. Anyway have fun with them it took me a while to gather all of these. You now get them in one shot. if you need any more help let me know and I will do all I can.


Hope this helps
Joe



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 3 of 16
(4,237 Views)
I think that the table is really the best way to go. Instead of using Read Characters From File, use the Read from Spreadsheet with a tab as a delimiter. There are instructions the diagram on how to modify the Read from Spreadsheet to return strings so all you would have to do is wire the output straight to the table.
0 Kudos
Message 4 of 16
(4,237 Views)
I think that the table is really the best way to go. Instead of using Read Characters From File, use the Read from Spreadsheet with a tab as a delimiter. There are instructions the diagram on how to modify the Read from Spreadsheet to return strings so all you would have to do is wire the output straight to the table.
0 Kudos
Message 5 of 16
(4,237 Views)
Since the table contain text headers, you would need to read the first line as string and write them to the column header property, then read the rest as spreadsheet, with the read offset correctly set.
0 Kudos
Message 6 of 16
(4,237 Views)
Thanks for this answer. This would be exactly right for me except that in case errors arise, they are shown in the data file where the numbers would have been. And there are other text elements there such as time stamps, so it's really a mix.

What I really want is to display the text file exactly as is on the screen. The computer has no Word or Excel installed, but could launch Notepad or Wordpad to display the file if I could figure out how.
- Thanks, Aaron.
0 Kudos
Message 7 of 16
(4,237 Views)
Thanks, Joe. I was very excited to download what you gave me, but unfortunately I wasn't able to make it work. I don't have Word or Excel installed on that machine, but I do have Wordpad and Notepad. What I want to do basically is display this text file exactly as it would appear in a simple text editor, or even launch a text editor to make it appear. The file is really a mixture of string text and tab-delimited numbers, where sometimes text error messages replace certain rows in the spreadsheet, and these are crucial for the operator of the machine to see. Also, since I'm running LabVIEW Base system, I don't have any of the report generation features, so no html.

Once again, thanks for your help.
Aaron.
0 Kudos
Message 8 of 16
(4,237 Views)
You can use the Sys Exec.vi in your communication palette to launch notepad.
use the command line:
notepad.exe "your file path and file name"
(don't use apostrophes)
0 Kudos
Message 9 of 16
(4,237 Views)
If the formatting is otherwise clean (tabs exclusively as separators, etc.) it should not be too difficult to write a little code that converts your string into a 2D array of strings that can be used to feed the table indicator.
0 Kudos
Message 10 of 16
(4,237 Views)