Datalogger modify a Text file
Michael @ Afineol
Posts: 33
I can now open a text file, read its contents and then write those contents to another text file. What I need to be able to do now is read a single character from a text file say "0". Store in a var, Increament it, and then overwrite "0" with "1". I tried the following code:
Before the code runs the TestUP.txt file contains: 30,0D,0A ("0CRLF")
After the code my TestUP.txt file now contains: 31 ("1") The CRLF is missing.
USBOffset := 0 IF logger.openFileForWrite(string("TestUP.txt"),0) logger.seek(USBOffset) logger.readFromFileUntilChar(string("TestUP.txt"),@arrUSBBuffer,CR,@USBOffset) logger.seek(0) TestFile := arrUSBBuffer[0] TestFile++ logger.writeToFile(@TestFile,1,0) logger.closeFile(string("TestUP.txt"))
Before the code runs the TestUP.txt file contains: 30,0D,0A ("0CRLF")
After the code my TestUP.txt file now contains: 31 ("1") The CRLF is missing.
Comments
My Spin skills are pretty weak, so this is more psedocode than anything, but see if this idea makes sense...
I commented out the lines I changed so you can see the difference. I'm not sure of the syntax on writeToFile, so I left place holders.