Go Down

Topic: Replacing records in sd file (Read 332 times) previous topic - next topic

orbitcoms

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?

PaulS

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.
The art of getting good answers lies in asking good questions.

Go Up