| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. File.WriteStr #740 Posted by: 2003-01-17 18:43:05 | This simple program works well, apparently, but makes something I don't understand.
File.Open("dati.txt", fmopenread) mystring$=File.Readstr(File.Size) File.Close mystring$=Replacesubstr$(mystring$, "retta", "rettissima") File.Open("dati.txt", fmopenwrite) lung%=len(mystring$) File.WriteStr(mystring$, lung%) File.Close
It adds a space at the end of my text file every time I run it. I made it work properly by giving the parameter lung% -1 in the WriteStr command, but still I'm puzzled. Can someone tell me why it does this?
Thanks in advance.
Cajino | 2. EOF #743 | I wonder whether it is EOF added by text mode filestream? | 3. no no no!! #744 Posted by: 2003-01-23 00:53:43 | Hi There!
It is the replacesubstr function, technically. if you check the result of it it will return one more byte in length (the null character). in turn the function is also 1 based instead of zero based so 8 will give a len of 9. No Problem? yes, because filestream is zero based! hence why you get an extra byte. Remember. filestream is binary. Its not bothered about eof+a space. The problems can occur when reading the file/length back in, if you dont correct with -1.
regards
john
| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|