Desorientado

Post Reply
jpcavagnaro
Posts: 35
Joined: Tue Aug 12, 2025 12:29 pm

Desorientado

Post by jpcavagnaro »

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:

Code: Select all | Expand

   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
User avatar
Enrico Maria Giordano
Posts: 9054
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Desorientado

Post by Enrico Maria Giordano »

This can't be working:

Code: Select all | Expand

   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.

Code: Select all | Expand

      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?

User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Desorientado

Post by karinha »

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
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Desorientado

Post by karinha »

PRUEBA ASI:

Code: Select all | Expand

//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
jpcavagnaro
Posts: 35
Joined: Tue Aug 12, 2025 12:29 pm

Re: Desorientado

Post by jpcavagnaro »

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
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Desorientado

Post by karinha »

"chequear si el dbf esta activo "

Algo asi?

Code: Select all | Expand

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

ó

Code: Select all | Expand

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

ó

Code: Select all | Expand

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
jpcavagnaro
Posts: 35
Joined: Tue Aug 12, 2025 12:29 pm

Re: Desorientado

Post by jpcavagnaro »

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
User avatar
Enrico Maria Giordano
Posts: 9054
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Desorientado

Post by Enrico Maria Giordano »

Try this sample:

Code: Select all | Expand

#include "Fivewin.ch"


FUNCTION MAIN()

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

? K_ESC

RETURN NIL

Result: Warning W0001 Ambiguous reference: 'K_ESC'

Now this:

Code: Select all | Expand

#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.

Post Reply