Welcome! Log In Create A New Profile

Advanced

fwrite bug

Posted by damato68 
fwrite bug
December 06, 2012 10:04AM
Hi,
the file function fwrite, fail to write without errors (return 0) if the variable string is flash saved

this write 1024 bytes to file
dim buff$[1024]
function ttt()
dim ln,fp,error
    fp=fopen("test.bin","w")
    error=fwrite(buff$,1024,?ln,fp)
    fclose(fp)
    return
endf


dim buff$[1024]
flsave("")

this write 0 bytes to file without error
function ttt()
dim ln,fp,error
    fp=fopen("test.bin","w")
    error=fwrite(buff$,1024,?ln,fp)
    fclose(fp)
    return
endf

And more, may be usefull to have a function that write from a string pointer instead of a string variable
example...
fwrite(?buff$+4,1024,?ln,fp)

Please fix it as soon as possible :)-D



Edited 1 time(s). Last edit at 12/06/2012 10:07AM by damato68.
Re: fwrite bug
December 06, 2012 11:06AM
The bug here is that the string looses its size in the first 4 bytes when saved to flash. To be fixed in the next release. A workround is to put the size back on reset thus:
poke(buff$,1024)
There is still a problem with the sizing of strings on version 69 so the global save needs looking at.
Re: fwrite bug
December 06, 2012 11:44AM
many thanks Jim
Sorry, you do not have permission to post/reply in this forum.