Problema Con Wait dentro de un Loop - Forum

Forum Navigation
You need to log in to create posts and topics.

Problema Con Wait dentro de un Loop

tengo el siguiente codigo que lo que hace es cargar los datos de una venta e imprimirlos en una subrutina creando un pdf, para darle tiempo a generar el archivo pdf al recibir los datos intento poner un wait pero no funciona :

Loop 0 [Boletas_Cantidad_2] [x]
  Wait 5000
    neoTableGetData [boletas] [x] "Boleta_Nro" [Boleta_Nro]
    neoTableGetData [boletas] [x] "Cliente" [Cliente]
    neoPhpExecSql "db1" "ventas_clientes_ver" "[Boleta_Nro]::[Cliente]::[Comercio]" "Boletas_Del_Dia_Imprimir_Todas"
  EndWait
endloop

Ese codigo directamente no funciona, esta puesto en un Boton

@gustavo1973

The reason it does not work is because of your misunderstanding about the f Wait/EndWait code block.

When you code a Wait/EndWait code block, only the code inside this block is delayed for the specified time; any command(s) after the EndWait command are serviced immediately.

So, in your case, while these commands are delayed ...

neoTableGetData [ballots] [x] "Boleta_Nro" [Boleta_Nro]
neoTableGetData [ballots] [x] "Customer" [Customer]
neoPhpExecSql "db1" "ventas_clientes_ver" "[Boleta_Nro]::[Client]::[Commerce]" "Boletas_Del_Dia_Imprimir_Todas"

... the command after the EndWait (i.e. EndLoop) is serviced immediately ... which loops back to the Loop command for the next iteration of the loop.

The subroutine called Boletas_Del_Dia_Imprimir_Todas is where the result of the neoPhpExecSql command is processed.

As to the correct way, I can't tell from the limited information presented in your post; in particular ...

a) does the Alias named ventas_clientes_ver create a separate PDF file (on the server) each time you invoke the neoPhpExecSql command ?

b) when done, what is returned to the specified subroutine ?

@gaev gracias por responder, intentare explicarte:

a) ¿El alias llamado  ventas_clientes_ver  crea un archivo PDF separado (en el servidor) cada vez que invoca el   comando neoPhpExecSql ?

No, el alias " ventas_clientes_ver " recibe diferentes datos (registros), los cuales en la subrutina se usan para crear el PDF mediante el plugin "NeoPdf" de visualNeoWeb y se imprime

Este procedimiento se repite con cada llamado del loop

 

@gustavo1973 utiliza un objeto Timer o bien el comando SetInterval.
Tu loop no se ejecuta cada 5 segundos (que entiendo es lo que pretendes), se ejecuta tan rápido como sea posible y por cada bucle se lanza una espera de 5000 milisegundos para el código que has puesto dentro del Wait. Es decir, pasados 5000 milisegundos, se ejecutarán TODOS ellos a la vez.

Gracias por la ayuda , al final lo pude hacer mediante como dices @luishp un Timer

Gracias tambien @gaev