FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Desorientado
Posts: 14
Joined: Tue Aug 12, 2025 12:29 PM
Desorientado
Posted: Wed Apr 08, 2026 09:58 AM

Hola gente, en un sistema de un restaurante me esta dando error eventualmente (una 0 2 veces por mes) y no entiendo que puede ser:

   if select( "mov_ven" ) = 0
      #INCLUDE "MOV_VEN"
   endif
   sele mov_ven
   if xefectivo <> 0
      jrlock()
      appe blank
      repl fecha     with date()    

      repl numero    with xfactura                ---------- Acá me da numero no existe la variable --------
      repl descri    with alltrim( xnombre ) + " " + strzero( xmesa, 3 ) + "-" + substr( time(), 1, 5 )
      repl factura   with xefectivo
      repl personas  with xpersonas
      repl vendedor  with xvendedor
      dbcommitall() ;      dbcommit() ;      dbunlock()
   endif

Siendo que trabajan todos los días sin problema, pero cada tanto da el error, es muy raro

Saludos
Jorge

Saludos

Jorge
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 01:03 PM

This can't be working:

   if select( "mov_ven" ) = 0
      #INCLUDE "MOV_VEN"
   endif

#include is a preprocessor directive, so it takes place BEFORE the program execution. In other words, the IF statement is useless.

      repl numero    with xfactura                ---------- Acá me da numero no existe la variable --------

This is harder. Maybe the workarea has been unexpectedly stealed by other portions of your code?

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 01:41 PM

Muestra en pantalla quién es xfactura. ¿Cómo se crea? ¿Alfanumérico o numérico? Muestra la solicitud GET para xfactura.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 02:03 PM

PRUEBA ASI:

//IF Select( "mov_ven" ) = 0
#include "MOV_VEN"  // Que hace?
// ENDIF

FUNCTION Tu_Functiob()

   SELE mov_ven

   SET ORDER TO... ? Esta correcto?

   SEEK xefectivo

   IF .NOT. FOUND() // INCLUSION

  APPEND BLANK

  RLOCK()

  REPLACE fecha     WITH Date()
  REPLACE numero    WITH xfactura
  REPLACE descri    WITH AllTrim( xnombre ) + " " + StrZero( xmesa, 3 ) + "-" + SubStr( Time(), 1, 5 )
  REPLACE factura   WITH xefectivo
  REPLACE personas  WITH xpersonas
  REPLACE vendedor  WITH xvendedor

  COMMIT
  UNLOCK

   ELSE // CAMBIAR.

  RLOCK()

  REPLACE fecha     WITH Date()
  REPLACE numero    WITH xfactura
  REPLACE descri    WITH AllTrim( xnombre ) + " " + StrZero( xmesa, 3 ) + "-" + SubStr( Time(), 1, 5 )
  REPLACE factura   WITH xefectivo
  REPLACE personas  WITH xpersonas
  REPLACE vendedor  WITH xvendedor

  COMMIT
  UNLOCK

   ENDIF

   /*
   IF xefectivo <> 0

  APPE BLANK // ES UNA INCLUSION?

  //   jrlock() //??
  RLOCK()

  // APPE BLANK // ES UNA INCLUSION?

  REPLACE fecha     WITH Date()
  REPLACE numero    WITH xfactura----------Acá me da numero no existe la variable--------
  REPLACE descri    WITH AllTrim( xnombre ) + " " + StrZero( xmesa, 3 ) + "-" + SubStr( Time(), 1, 5 )
  REPLACE factura   WITH xefectivo
  REPLACE personas  WITH xpersonas
  REPLACE vendedor  WITH xvendedor

  // ???                  ???               correct!
  // dbCommitAll() ;      dbCommit() ;      dbUnlock()

  COMMIT
  UNLOCK

   ENDIF
   */

RETURN NIL

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 14
Joined: Tue Aug 12, 2025 12:29 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 02:38 PM

Gracias por responder.

IF Select( "mov_ven" ) = 0 #include "MOV_VEN" // Que hace? ENDIF

es para chequear si el dbf esta activo, sino en el include esta el sele ......

lo puse por las dudas estuviese inactivo.

lo raro es que funciona siempre (es un restaurante que tiene muchas mesas y trabaja mucho) y muy de ves en cuando da el error

y el cliente no me dice hice esto y dio el error, el dice que siempre hace lo mismo

Saludos Jorge

Saludos

Jorge
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 03:06 PM

"chequear si el dbf esta activo "

Algo asi?

IF Used()
   MsgInfo("La base de datos está abierta")
ELSE
   MsgInfo("La base de datos está cerrada")
ENDIF

ó

IF Select("CLIENTES") > 0 .AND. Used()
    // Está abierta
ENDIF

ó

USE tabla SHARED NEW
IF NetErr()
   MsgStop("No se pudo abrir la tabla, está en uso exclusivo por otro usuario")
ELSE
   // Tabla abierta exitosamente
ENDIF

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 14
Joined: Tue Aug 12, 2025 12:29 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 03:46 PM

probe con:

IF Used() MsgInfo("La base de datos está abierta") ELSE MsgInfo("La base de datos está cerrada") ENDIF

esto lo puse en la apertura del dbf

USE tabla IF NetErr() MsgStop("No se pudo abrir la tabla, está en uso exclusivo por otro usuario") ELSE // Tabla abierta exitosamente ENDIF

y funciona, veremos si vuelve a dar el error

Muchas gracias.

Saludos Jorge

Saludos

Jorge
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Desorientado
Posted: Wed Apr 08, 2026 09:21 PM

Try this sample:

#include "Fivewin.ch"


FUNCTION MAIN()

IF .F.
//        #include "Inkey.ch"
    ENDIF

? K_ESC

RETURN NIL

Result: Warning W0001 Ambiguous reference: 'K_ESC'

Now this:

#include "Fivewin.ch"


FUNCTION MAIN()

IF .F.
    #include "Inkey.ch"
ENDIF

? K_ESC

RETURN NIL

Result: 27

This demonstrates that the IF statement is useless.

Continue the discussion