Page 1 of 1

Test network connection?

Posted: Mon Jun 22, 2015 5:39 pm
by DonDrew
I'm having trouble with a customer application which seems to loose its network connection from time to time.

Does anyone know of a technique that will allow me to test if a workstation is still connected to a LAN?

Don

Re: Test network connection?

Posted: Mon Jun 22, 2015 6:40 pm
by Marc Vanzegbroeck
Don,

You can check if a file exist on the network-directory with IF FILE() like.

Code: Select all

IF !FILE(...)
   msgalert('Networkdrive error')
ENDIF

Re: Test network connection?

Posted: Mon Jun 22, 2015 8:17 pm
by karinha

Code: Select all

   IF .NOT. FILE( "CADNFE.DBF" ) .OR. .NOT. FILE( "CADCESVE.DBF" ) .OR.     ;
      .NOT. FILE( "ICESVE.CDX" ) .OR. NETERR()

      ...

   ENDIF
 
Regards,

Re: Test network connection?

Posted: Tue Jun 23, 2015 12:30 pm
by DonDrew
Marc & Karinha
Thanks for your suggestions.

I've used your ideas plus a few of my own to add enhancements to errsysw.prg which I hope will help me catch possible network errors.

Thanks again.

Don

Re: Test network connection?

Posted: Tue Jun 23, 2015 6:58 pm
by karinha
In ERRSYSW.PRG

Code: Select all

   IF .NOT. EMPTY( e:osCode )

      ? "Error in NetWork"

   ENDIF
   

Code: Select all

   IF UPPER(e:Description)="CORRUPTION DETECTED" 

      ? "Corruption Detected"

   ENDIF
   

Please, translate for ingles.

Code: Select all

   IF UPPER(e:Description) = "LOCK REQUIRED"                  .OR. ;
      UPPER(e:Description) = "TRAVAMENTO REQUERIDO"           .OR. ;
      UPPER(e:Description) = "FALHA NO TRAVAMENTO"            .OR. ;
      UPPER(e:Description) = "FALHA NO TRAVAMENTO DO APPEND"  .OR. ;
      UPPER(e:Description) = "USO EXCLUSIVO REQUERIDO"        .OR. ;
      UPPER(e:Description) = "Erro DBFCDX/1002 erro ao Abrir" .OR. ;
      UPPER(e:Description) = "Erro DBFCDX/1002 erro Open (DOS Erro 2)" .OR. ;
      UPPER(e:Description) = "Error DBFCDX/1002 Open error"    .OR.;
      UPPER(e:Description) = "Error DBFCDX/1002 Open error (DOS Error 2)" .OR.;
      UPPER(e:Description) = "(DOS Error 2) DBFCDX/1002 ERRO DE ABERTURA" .OR.;
      UPPER(e:Description) = "Erro DBFCDX/1001 erro ao Abrir"             .OR.;
      UPPER(e:Description) = "Erro DBFCDX/1001 erro Open (DOS Erro 2)"    .OR.;
      UPPER(e:Description) = "Error DBFCDX/1001 Open error"               .OR.;
      UPPER(e:Description) = "Error DBFCDX/1001 Open error (DOS Error 2)" .OR.;
      UPPER(e:Description) = "Error DBFCDX/1201 WORKAREA NOT INDEXED"     .OR.;
      UPPER(e:Description) = "ERROR DBFCDX/1201 WORKAREA NÇO INDEXADA"    .OR.;
      UPPER(e:Description) = "Error DBFCDX/1012 Corruption detected"      .OR.;
      UPPER(e:Description) = "ERROR DBFCDX/1012 CORRUPTION DETECTED"      .OR.;
      UPPER(e:Description) = "Error DBFCDX/1210 Corruption detected"      .OR.;
      UPPER(e:Description) = "ERROR DBFCDX/1210 CORRUPTION DETECTED"      .OR.;
      UPPER(e:Description) = "(DOS ERROR 64) DBFCDX/1010  ERRO DE LEITURA".OR.;
      UPPER(e:Description) = "(DOS Error 2) DBFCDX/1001 ERRO DE ABERTURA"

      ? "Error in .DBF"

   ENDIF