Arduino Forum

Using Arduino => Storage => Topic started by: orbitcoms on Jul 05, 2017, 05:25 am

Title: Replacing records in sd file
Post by: orbitcoms on Jul 05, 2017, 05:25 am
I have an application that I need to store fixed length records into file on SD card and then transmit the files in batches to another application. The other application is not always available so I need to be able to handle sending some of the records from the file and later sending more. Once all files are sent then I can re-write the file back to zero bytes and start again.

Is there a way to get the number of lines of text in a file and also to set some sort of pointer where to get next records from? or better, to advance to the required line of text?
Title: Re: Replacing records in sd file
Post by: PaulS on Jul 05, 2017, 12:15 pm
Quote
Is there a way to get the number of lines of text in a file
No. You can get the number of bytes in the file. Divide that by the number of bytes in a record to get the number of records. The file has no idea how many bytes are in a record, so it can't tell you how many records there are.

Quote
and also to set some sort of pointer where to get next records from?
You can use seek() to go to a specific location to start reading.