LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble writing 1d array of strings to file

I have to read values from a text file, locate specific ones and write them to file again. I have been trying to creatre the attached vi for the task. It will read in the values I need but when I read in the file a second time, I loose some data on the concatonated lines.
Please see the attached and use the HSFACTOR.txt file as the sample. (You might want to make backups of it).
I appreciate any suggestions on what I can do to make the task easier.
Thanks
0 Kudos
Message 1 of 3
(2,517 Views)
I took a look at your VI and to be honest I am not totally sure what I am seeing versus what I should be seeing. Hopefully these observations will help you track down the issue.
I did notice that the string
"\tSN\sD85923;\s500-lb;\s\sHTH\sSN\s#06-29-01298184\r\n"
seems to get shorter every time it is run and that the data runs together. It becomes
"\tSN\sD85923;\s25\slb;\s\s\sHTH\sSN\s#06-29-01298184\r\n" then
"\tSN\sD85923;25\slb;\s\s\s\sHTH\sSN\s#06-29-01298184\r\n"
I believe this is due to you stripping the last 4 characters off the string in the true case with a comment "whole str". You then concatenate the new value on to the string, without adding a delimiter. So basically every time you run it you remove 4 characters; however you are only adding 2 with
the new value. So every time you run it you are guaranteed to lose 1 character minimum.
0 Kudos
Message 2 of 3
(2,517 Views)
Evan:
Thanks for looking at the problem. Yes. the shifting is what I'm trying to prevent. I will try padding the input var with spaces.
0 Kudos
Message 3 of 3
(2,517 Views)