LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to update specific records(of variable lengths) in a file. I can get the correct record but when I update it(add info), it overwrites part of the record following it. I am using labview 6.0

I need to update specific records(of variable lengths) in a file. I can get the correct record but when I update it(add or change info), it overwrites part of the record following it. I am using labview 6.0. I need to be able to insert information into the middle of a file without disturbing the data before and after
0 Kudos
Message 1 of 4
(2,822 Views)
It's hard to give more specifics without more detail, but in general you're going to need to read in the entire file, split it into three pieces (everything before the record of interest, the record itself, and everything after the record of interest), modify the record, reassemble the three pieces in proper order, and write the whole thing back to the file.Of course if the file is very large you might not want to actually implement it this way, but conceptually at least, this is what you are looking at.If this file some sort of proprietary format?Mike...PS: this type of issue is why I really like databases...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 4
(2,822 Views)
Hi,
may be I'm not right but it seems to me that problem in that you don't care about read/write marker position in your file. I mean the following:
1.you open the file.
2.then you read some record. after this reading the marker moves to the next record.
3.then you change the value of record and writes it to the file. But as the marker is located at the next record you actually update incorrect record.

If I'm right then all you need to do is to move the marker to the previous position after reading.

The best way for you is to send your vi here, because it is dificult to say something without seeing it.


Good luck.

Oleg Chtuko.
0 Kudos
Message 3 of 4
(2,822 Views)
To accomplish this task as you intend, the original file should be a fixed record length.

If you can not dictate the foramt of the orignal file, you will be forced to use the techniques mentioned by others to re-write everything after the update.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 4
(2,822 Views)