Dave I haven't recently experienced exactly this with MapBasic though it can
happen with VB6 (etc) in the circumstance you mentioned (" .. possible that
the application might not have closed it properly at it's last attempt."). 
After this occurs, it might be useful to see if you can delete or move that
log file (using Windows Explorer), as a test of whether it was actually
locked at the time the OnError failed. 

IL Thomas
GeoSciSoft - Perth, Australia

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, September 15, 2006 10:46 AM
To: [email protected]
Subject: [MI-L] Error message despite error trap?

Is OnError unable to trap some kind of errors?

I have the following code:

'***************************************************************************
*
' LogMessage: Writes messages to a log file
'
Sub LogMessage

        OnError goto ErrorHandler
        Open File ApplicationDirectory$() + "MVMMapInfo.LOG" For Append As
#5
        Print #5, CurDate() + " " + " " + Time(24) + " " + Message
        Close File #5             
        OnError Goto 0

        Exit Sub

ErrorHandler:             
        Close File #5             
        TempText = "Error in LogMessage: " & Err() & " " & Error$() &
Message
        Print TempText
        Call LogDebug(TempText) 
        OnError goto 0
        Exit Sub

End Sub


However, my application occasionally crashes at the line after the OnError
line, i.e.
Open File ApplicationDirectory$() + "MVMMapInfo.LOG" For Append As #5

The error is:

"Cannot access file MVMMapInfo.LOG"

Has anyone seen this happen before where the OnError trap is ignored (or at
least I 
assume it is being ignored...)
I don't have the MVMMapInfo.LOG file open at the time the error occurs,
though it is 
possible that the application might not have closed it properly at it's last
attempt.

Thanks,

Dave
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006

_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to