#include "basic.ch"
#include "fileio.ch"
#include "ot4xb.ch"

EXIT Procedure _QUIT( nEl, cTXT )
*
*Begin
   Local nH, cIP, i, j, oAI
   dbCloseAll_()
   i    := 1
   j    := 'Fecha ' + DToC( Date() ) + ' Hora ' + Time() + CR_
   cTXT := j + If( (ValType( cTXT ) = 'C'), cTXT + CR_, '' )
   nEl  := If( (ValType( nEl ) = 'N'), nEl, 0 )
   nH   := FOpen( M->DIR_CEN + 'SALIDASQUIT.TXT', FO_READWRITE )
   If ( nH = F_ERROR )
      nH :=FCreate( M->DIR_CEN + 'SALIDASQUIT.TXT', FC_NORMAL )
   EndIF
   FSeek( nH, 0, FS_END )
   While ( !Empty( ProcName( ++i ) ) )
      cTXT += Trim( ProcName( i ) )
      cTXT += "(" + LTrim( Str( ProcLine(i) ) ) + ")" + CR_
   EndDO
   oAI   := _aGetAdapterInfo()                 // tomo las direcciones IP
   For i :=1 To Len( oAI )               // testeo que este en el servidor definido en seteos.ini
      For j :=1 To Len( oAI[i]:aIPList )
         cTXT += "( " + oAI[i]:aIPList[j] + " )"
      Next j
   Next i
   cTXT += CR_
   cTXT += Replicate( '-', 40 ) + CR_
   FWrite( nH, cTXT )
   FClose( nH )
   ErrorLevel( nEl )                           // Program can not or should not be continued
   @kernel32:ExitProcess( nEl )
   Return
*End;
*
