The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Don57 on November 10, 2011, 11:34:29 PM

Title: Clearing existing error messages
Post by: Don57 on November 10, 2011, 11:34:29 PM
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.
Title: Re: Clearing existing error messages
Post by: jj2007 on November 11, 2011, 12:06:00 AM
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

Title: Re: Clearing existing error messages
Post by: Don57 on November 11, 2011, 12:22:30 AM
Didn't seem to do the trick, let me check my code again. Thanks
Title: Re: Clearing existing error messages
Post by: jj2007 on November 11, 2011, 12:52:57 AM
> 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.
Title: Re: Clearing existing error messages
Post by: MichaelW on November 11, 2011, 01:31:54 AM
Some functions clear the last-error code value on success, and some do not.
Title: Re: Clearing existing error messages
Post by: dedndave on November 11, 2011, 02:04:27 AM
test to see if the file exists before the write
you can hook the save file dialog and add a message box
Title: Re: Clearing existing error messages
Post by: dedndave on November 11, 2011, 02:16:03 AM
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
Title: Re: Clearing existing error messages
Post by: dedndave on November 11, 2011, 04:26:21 PM
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
Title: Re: Clearing existing error messages
Post by: dedndave on November 11, 2011, 08:15:00 PM
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
Title: Re: Clearing existing error messages
Post by: Don57 on November 12, 2011, 07:14:17 PM
Thanks
Title: Re: Clearing existing error messages
Post by: dedndave on November 12, 2011, 11:54:42 PM
well - if the proposed file name exists as a folder, it opens the folder
guess that isn't really a problem   :P