#include "fileio.ch"

Function dbCloseAll_()
*
*Begin
   Local i, aNOK, oErr
   oErr := ErrorBlock( { | x | Break( x ) } )
   BEGIN SEQUENCE
   dbCloseAll()
   RECOVER
   aNOK  := {}
   For i := 1 To 1000
      If ( !Empty( Alias( i ) ) )
         If ( ( i )->( dbCloseArea() ) != NIL )
            AAdd( aNOK, Alias( i ) )
         EndIF
      EndIF
   Next i
   If ( Len( aNOK ) > 0 )
      i :=FOpen( M->DIR_CEN + 'DBFCLOSEERROR.TXT', FO_READWRITE )
      If ( i = F_ERROR )
         i :=FCreate( M->DIR_CEN + 'DBFCLOSEERROR.TXT', FC_NORMAL )
      EndIF
      FSeek( i, 0, FS_END )
      FWRite( i, Var2Char( aNOK ) + Chr( 13 ) + Chr( 10 ) )
      FClose( i )
   EndIF
   END SEQUENCE
   ErrorBlock( oErr )
   Return ( NIL )
*End;
*