News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Clearing existing error messages

Started by Don57, November 10, 2011, 11:34:29 PM

Previous topic - Next topic

Don57

I am using Olly to debug my code. During the writing of a data file, I check to see if the file already exists. If it does, a dialog asks the user if it is alright to overrite the file.
The file_already_ exists error is the switch for the dialog. However the file_already_exists error stays up on the Olly interface, even though furthur invokes are sucessfull.
Is there any way to clear the error once I have delt with it. It makes debugging the code after it, needlessly complicated.

jj2007

I have never had such problems with Olly, but you can try one of the following:

invoke SetLastError, 0

debugging = 1
ife debugging
  invoke ShowWarning
endif


Don57

Didn't seem to do the trick, let me check my code again. Thanks

jj2007

> the file_already_exists error stays up on the Olly interface

In case you mean "Olly keeps the LastErr message in the middle of its upper right window": Don't blame Olly. Clear the message by using SetLastError, 0 after the invoke that triggers the error.

MichaelW

Some functions clear the last-error code value on success, and some do not.
eschew obfuscation

dedndave

test to see if the file exists before the write
you can hook the save file dialog and add a message box

dedndave

#6
forgot to mention...
i use the same code to test if the file exists as i do to get the file size (the other thread)   :U

also - you can use SetLastError to clear the error code
oops - Jochen told you that, already   :P

dedndave

here is a save file dialog
it hooks the Save File dialog to test for overwrite
it also hooks the message box to alter the button text

dedndave

looking at that code - it could use a slight improvement
if the filename exists as a folder, it could show a message box
i may play with it later today   :P

Don57


dedndave

well - if the proposed file name exists as a folder, it opens the folder
guess that isn't really a problem   :P