Im trying to figure out what the best way to move some data between two txt files on an SD card is.
I have 2 files, "send" and "archive" What im trying to do is move the data from send to archive.
Each one that is open needs a 512 byte buffer, which may use up all (or more) of your memory.
You could open a file, position the cursor, read a record, close the file, open the other file, append the data, and close the file, until the first file had been copied.
H4rdstyler:
Im trying to figure out what the best way to move some data between two txt files on an SD card is.
I have 2 files, "send" and "archive" What im trying to do is move the data from send to archive.
Whats the best way of doing this?
That's a very vague description of what you want to do.
Your description could either mean:
delete "archive" file
rename "send" file to "archive"
Or the meaning could be:
open "archive" for appending data
read data from "send" and append to "archive"
when ready, delete "send"
You can have open more than one file at a time. But each file opened will cost you 512 bytes (or a bit more) of dynamic dynamically allocated SRAM, so most likely you need an MEGA2560 to have enough SRAM to do so.
Because all the examples says so, I assume thats wrong.
PaulS:
Each one that is open needs a 512 byte buffer, which may use up all (or more) of your memory.
You could open a file, position the cursor, read a record, close the file, open the other file, append the data, and close the file, until the first file had been copied.
Thats what im wondering, where do i "copy" and/or temporarily store the data after closing the send file? I know using a string isnt very effecient, allthou the data amounts are small (roughly 50 bytes) per line.
jurs:
That's a very vague description of what you want to do.
Its a very simple question, no need to elaborate in extreme details.
Post #3 gives you a blueprint and you can debate it until the cows get home, but doing so means the net work accomplished is zero. Write it up as stated there and see what happens. If those "other sources" are correct, it won't work. If they are wrong, it will work and your problem's solved. Give it a try.