Title: Re: [amibroker] How to fclose()/fdelete() left open files from afl
I am now using this, somewhat awkward, method to monitor file open/close operations. I wrapped fopen() with xfopen() and fclose() with xclose().
I post this just in case someone has similar debugging problems.
Herman
function Trace( Msg )
{
TraceEnabled = Nz( StaticVarGet( "TraceEnabled" ) );
if ( TraceEnabled ) _TRACE( Msg );
}
function TRACEONCE( Msg )
{
TraceEnabled = Nz( StaticVarGet( "TraceEnabled" ) );
if ( TraceEnabled )
{
PrevMessage = StaticVarGetText( "LastTraceMsg" );
if ( PrevMessage != Msg )
{
_TRACE( Msg );
StaticVarSetText( "LastTraceMsg", Msg );
}
}
}
function xfopen( filename, mode )
{
fh = fopen( filename, mode );
StaticVarSetText("FM"+fh, filename + " Mode: "+Mode );
TraceOnce("FILE Opened: "+ filename+ " Mode: "+Mode);
return fh;
}
function xfclose( Handle )
{
fclose( Handle );
FileMode = StaticVarGetText("FM"+Handle );
TraceOnce("FILE Closed: "+ FileMode );
}
Thursday, October 30, 2008, 8:46:25 AM, you wrote:
>
|
It often happens during development that, due to coding errors, files are not closed. The only way to close these file appears to be to use an external UnLock program to UnLock and delete the file. Since I use many files it is very time consuming to locate the open files and the afl errors that caused them.
I'd like advice from experienced programmers on how to detect, locate, and close files left open due to mistakes, from afl of course.
many thanks for any suggestions you may have,
herman
|
__._,_.___
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
*********************************
__,_._,___
|