torpark
27th October 2006 17:59 UTC
FileWrite throws arbitrary error
I have opened a file like so:
FileOpen $4 "$EXEDIR\${NAME}.log" w
No problem there. But when I write a line to the file, it indeed writes the line, but throws an error flag.
${time::GetLocalTime} $R0
FileWrite $4 "$R0 This is some note $\n"
So the open/append and writing works, but IfErrors is set for some reason. I tried IfErrors after "time", but that wasn't it. Ideas?
kichik
27th October 2006 18:05 UTC
Are you sure it's not time::GetLocalTime that sets the error flag? You should always call ClearErrors before calling the instruction that you wish to test with IfErrors.
torpark
27th October 2006 21:50 UTC
Yes. I am entirely sure. I broke the lines apart with IfErrors, and time did not throw a flag (and IfErrors performs ClearErrors)
kichik
27th October 2006 22:15 UTC
Well, FileWrite only sets the error flag if the handle is invalid or WriteFile returns an error code. So, unless time corrupts $4 or something else sets the error flag, there's a disk error and that's very unlikely. Can you attach the script?
torpark
28th October 2006 09:46 UTC
Sure. But it is a long script. Btw, I opened the file using a function, and write to it outside of the function. I doubt that matters but who knows, I've managed to corrupt the stack with execdos.
kichik
28th October 2006 10:57 UTC
I don't see any FileWrite accompanied with IfErrors in that script.
torpark
28th October 2006 17:20 UTC
Check procedure ReadINI.
I wanted to put in FileWrites all throughout it, but it kept of throwing errors there. I removed all the FileWrites and substituted MessageBoxes.
kichik
28th October 2006 17:24 UTC
I can't see in that script if you've really used ClearErrors and IfErrors correctly and there's something else. That's not the script that reproduces the problem. And if it is, then the problem is that you don't have ClearErrors before FileWrite.