Writing to same line on an SD card

Hello,

im writing some data to sd card, by writing new line of data for each change. It all works fine, but because this setup will be installed into some bigger prototype device systems samples that will be away from me for couple of months, there will be a loooot of data stored there. One of the data is a count of some cycles and i type down the each new value in new line, for example:

NUMBER OF CYCLES 2 3 4 5 6 7 ...

Is it possible to just setup matrix or some function that would always write on same spot in sd card, so that it would look like this(each new cycle count would be typed on same spot): NUMBER OF CYCLES = 7

Thanks in advance fro any help :D

You could use the 'find()' function to search for "NUMBER OF CYCLES = ". If the search string is found, the function returns 'true' and leaves the file pointer at the first character after the search string, ready for writing the new value.

If the search string is in the middle of the file, and not at the end, you'd need to write the same number of characters each time though, to avoid overwriting any following data. Perhaps 0001, 0002.....0075 etc rather than 1, 2....75 and so on.

You need to ensure that the file pointer is at the beginning of the file before calling 'find()'. If opened in "WRITE" mode, the file pointer is initially at the end of the file. 'seek(0)' will position the file pointer at the beginning of the file.

Edit: The 'find()' function can be found in the "Stream" section of the Arduino reference.

thanks you very much :DD