Page 3 of 3
Re: recursive call causing stack overflow.
Posted: Tue Nov 13, 2018 2:58 pm
by andyglezl
franco wrote: ↑Tue Nov 13, 2018 7:57 am
But could not find it on computer. I wanted to make sure it was getting rid of it.
Que bueno que ya estes seguro, aunque yo lo crei desde que leí esto.
*---------------------------------------------------------------------------------------
Good thing you're already safe, although I believed it since I read this.
[Harbour] DBCREATETEMP() patch
Viktor Szakáts Sun, 15 Feb 2009 16:23:06 -0800
Hi all,
Pls find enclosed patch which implements:
dbCreateTemp( <cAlias>, <aStruct>, <cRDD>, <cDelimArg>, <cCodePage>,
<nConnection> ) -> <lSuccess>
This creates and opens a new temporary table. The file automatically
gets deleted on close, all indexes created are also handled as temporary.
Please review and comment.
Brgds,
Viktor
I like your way of creating a temporary mem table it is much faster. I created a 1,000,000 record table both ways. 5 seconds your way, 20 second
hb_dbcreate way.
Esto es otro indicativo de que el archivo con DBCREATETEMP() se crea en HDD y no en memoria.
*------------------------------------------------------------------------------------..................................
This is another indication that the file with DBCREATETEMP() is created in HDD and not in memory.
Re: recursive call causing stack overflow.
Posted: Tue Nov 13, 2018 5:29 pm
by franco
Thanks again Andy, I am going to switch my reports to your way for temp files, much faster.
Franco
Re: recursive call causing stack overflow.
Posted: Tue Nov 13, 2018 5:39 pm
by andyglezl
De nada Franco, así todos aprendemos.
Aquí seguimos.
*-----------------------------------------------------
You're welcome Franco, so we all learn.
Here we continue.
Re: recursive call causing stack overflow.
Posted: Sat Dec 01, 2018 8:01 pm
by SALINETAS24
Hola Andy .., tu programa funciona muy bien, pero cuando necesitamos en la validación abrir una ventana para mostrar un Grid o cualquier otra cosa .., seguimos teniendo problemas.
¿hay alguna forma de evitarlo ese problema..?
Code: Select all
*------------------------------------------------------------------------------------------------------
FUNCTION CkCtrolValue( cWind, cCtrol )
IF EMPTY( GetProperty( cWind, cCtrol, 'Value' ) )
DoMethod( cWind, cCtrol, 'SetFocus' )
SetProperty( cWind, 'L_Warning', 'Value', 'FIELD ' + CCTROL + ' CAN NOT BE EMPTY!' )
Form_main.L_Warning.Show
MIRA_VER()
StopControlEventProcedure( cCtrol, cWind, .f. ) // No permite Salir del TEXTBOX // Does not allow Exit from TEXTBOX
ELSE
Form_main.L_Warning.Hide
ENDIF
RETURN( .t. )
*------------------------------------------------------------------------------------------------------
FUNCTION MIRA_VER()
IF !IsWIndowActive (Form_main1)
DEFINE WINDOW Form_Main1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 600 ;
TITLE 'ON LOST FOCUS TEST'
@ 100,100 textbox T1 ;
WIDTH 150 HEIGHT 20 ;
VALUE ''
END WINDOW
CENTER WINDOW Form_Main1
ON KEY ESCAPE OF FORM_MAIN1 ACTION FORM_MAIN1.RELEASE
ACTIVATE WINDOW Form_Main1
ENDIF
RETURN
andyglezl wrote: ↑Thu Nov 08, 2018 11:45 pm
Sobre el comentario de Mol, aquí está un ejemplo, para ver si les sirve.
*--------------------------------------------------------
About Mol's comment, here is an example, to see if it serves you.
valida.png
Code: Select all
/* Ejemplo para validar texboxs no vacios ----- AndyGlezL */
/* Example to validate non-empty texboxs ----- AndyGlezL */
#include "hmg.ch"
FUNCTION Main()
DEFINE WINDOW Form_Main AT 0,0 WIDTH 640 HEIGHT 600 TITLE 'ON LOSTFOCUS TEST ´By AndyGlezL' MAIN
SET NAVIGATION EXTENDED // Para que al oprimir ENTER tambien valide // so that when pressing ENTER also validate
ON KEY ESCAPE OF Form_main ACTION Form_main.Release
@ 10 , 10 LABEL L_Warning WIDTH 250 HEIGHT 20 VALUE '' SIZE 12 FONTCOLOR WHITE BACKCOLOR RED BOLD CENTERALIGN
Form_main.L_Warning.Hide
nReng := 60
nCpos := 10
FOR i1 = 1 TO nCpos
nColu1 := 10
nColu2 := 90
nReng += 25
cLBOpc := "LBL_"+STRZERO( i1, 2 )
cTBOpc := "TXB_"+STRZERO( i1, 2 )
@ nReng , nColu1 LABEL &cLBOpc. OF Form_Main VALUE 'TEXT'+STRZERO( i1, 2 ) WIDTH 80 HEIGHT 20
@ nReng , nColu2 TEXTBOX &cTBOpc. OF Form_Main VALUE '' WIDTH 150 HEIGHT 20 ON LOSTFOCUS CkCtrolValue( ThisWindow.Name, This.Name )
NEXT
END WINDOW
CENTER WINDOW Form_Main
ACTIVATE WINDOW Form_Main
RETURN
*------------------------------------------------------------------------------------------------------
FUNCTION CkCtrolValue( cWind, cCtrol )
IF EMPTY( GetProperty( cWind, cCtrol, 'Value' ) )
DoMethod( cWind, cCtrol, 'SetFocus' )
SetProperty( cWind, 'L_Warning', 'Value', 'FIELD ' + CCTROL + ' CAN NOT BE EMPTY!' )
Form_main.L_Warning.Show
StopControlEventProcedure( cCtrol, cWind, .f. ) // No permite Salir del TEXTBOX // Does not allow Exit from TEXTBOX
ELSE
Form_main.L_Warning.Hide
ENDIF
RETURN( .t. )
*------------------------------------------------------------------------------------------------------
Re: recursive call causing stack overflow.
Posted: Sun Dec 02, 2018 5:18 pm
by andyglezl
Hola Salinetas
El "ON LOSTFOCUS CkCtrolValue( ThisWindow.Name, This.Name )" de cada contro TEXTBOX, seguirá ejecutandose
mientras "NO TENGA EL FOCO" o cada vez que el control lo pierda. Por lo tanto si abres otra VENTANA y creas otro
TEXTBOX (estos adquieren el FOCO), y de ahì viene la recursividad.
Este ejemplo es para cuando los TEXTBOX estén vacios y nada mas.
Por lo que comentas (y yo entiendo), veo que tu quieres validar el contenido y si está vacio, mostrar otro control para
que seleccionen lo correcto.
*-------------------------------------------------------------------------------------------------------------------------------------------------------
Hello Salinetas
The "ON LOSTFOCUS CkCtrolValue (ThisWindow.Name, This.Name)" of each TEXTBOX control will continue to run
while "DO NOT HAVE THE FOCUS" or every time the control loses it. So if you open another WINDOW and create another
TEXTBOX (these acquire the FOCUS), and from there comes the recursion.
This example is for when the TEXTBOX are empty and nothing else.
For what you comment (and I understand), I see that you want to validate the content and if it is empty, show another control to
that they select the correct thing.
Re: recursive call causing stack overflow.
Posted: Sun Dec 02, 2018 7:21 pm
by SALINETAS24
Exacto.., en clipper (y en la contabilidad que publique en este mismo foro), cuando un campo "codigo" esta vacio muestro una ventana con un Browse del fichero y el usurario puede seleccionar cualquier registro, o incluso dar de alta si el numero introducido no existe.
Cuando tengo un LOSTFOCUS no tengo problema, el lio lo tengo cuando tengo varios LOSTFOCUS seguidos.., sigo teniendo problemas, no entiendo que tenga cambiar o introducir un Textbox sin un LOSTFOCUS en medio para que me funcione...
Tendria que haber alguna forma para evitar esa recursividad. Un mantenimiento que pida, el "Codigo de Cliente", "Codigo de Mayorista", "Codigo de Servicio".., por ejemplo para una agencia de viajes..., es un bloqueo constante con la "merde" del LOSTFOCUS.
Deberia de existir una escpecie de ACTION como en los botones.., joder.
Re: recursive call causing stack overflow.
Posted: Sun Dec 02, 2018 10:18 pm
by SALINETAS24
Hola a todos.., he realizado unas modificaciones y ahora permite en los LOSTFOCUS abrir una ventana para pedir datos, mostrar un grid, ETc..., aunque vayan uno detrás del otro....
El ejemplo .., activara la función cuando la entrada este vacia... y para salir e ir al siguiente campo en la 2ª ventana tendremos que escribir algo.., en caso contrario nos quedaremos en el mismo TEXTBOX.
Con esto, en principio se evitan los problemas de "RECURSIVIDAD" y la perdida de "FOCUS".
Lo que he detectado ahora, es un algo ?¿?¿ cuando toma el focus.., necesito darle un click.., no se.., igual haciendo un refresh o igual es mania mia.
En fin.., estoy hasta los mismisimos de tanta tonteria para poder validar más de un campo seguido.
A ver si de esta forma ya lo tenemos. Mecagonto..
Ale .., unas cervecitas bien fresquitas para todos.
Code: Select all
/*
* HMG - Harbour Win32 GUI library Demo
*
* Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
* http://www.hmgforum.com//
*
* MODIFICACION PARA VARIOS LOSTFOCUS REALIZADA POR SARGANTANA.SOFT
* QUE ACTIVA UNA VENTANA PARA PODER HACER LO QUE SE QUIERA.
* José Manuel Carbonell Bernabe
* SargantanaSoft@Gmail.com
* Petrer City - Alicante - Spain.
*/
#include "hmg.ch"
#define WM_KILLFOCUS
Function Main
LOCAL LOk:=.t.
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'HMG Demo' ;
MAIN
@ 10,10 TEXTBOX Text_1 ;
TOOLTIP 'Pon algo' ;
VALUE "Uno ";
ON LOSTFOCUS if(empty(This.Value),;
IF(Poner_ventana("Text_1","Form_1",@lOk ),nil,msgbox("ME QUEDO") ),NIL)
@ 40,10 TEXTBOX Text_2 ;
TOOLTIP 'Pon algo' ;
VALUE "dos ";
ON LOSTFOCUS if(empty(This.Value),Poner_ventana("Text_2","Form_1",@lOk ),nil)
@ 70,10 TEXTBOX Text_3 ;
TOOLTIP "Pon algo" ;
VALUE "PonAlgo" ;
ON LOSTFOCUS if(empty(This.Value),Poner_ventana("Text_2","Form_1",@lOk ),nil)
@ 100,10 TEXTBOX Text_4 ;
TOOLTIP 'Numeric TextBox' ;
NUMERIC ;
MAXLENGTH 5 ;
RIGHTALIGN
@ 130,10 TEXTBOX Text_5 ;
TOOLTIP 'Numeric TextBox' ;
NUMERIC ;
MAXLENGTH 5 ;
RIGHTALIGN
END WINDOW
Form_1.Center
Form_1.Text_1.Setfocus
Form_1.Activate
Return Nil
STATIC func Poner_Ventana(cTitulo,cForm)
LOCAL cVar:=""
Local cTrol:=""
LOCAL lOk:=.t.
IF !EMPTY(GetProperty( cForm, 'FocusedControl'))
DEFINE WINDOW Form_Main1 ;
AT 0,0 WIDTH 240 HEIGHT 200 ;
TITLE 'pon algo para cambiar focus';
MODAL ;
BACKCOLOR BLUE
@ 100,100 textbox T1 WIDTH 150 HEIGHT 20 VALUE '' ;
on lostfocus(cVar:=This.Value)
END WINDOW
CENTER WINDOW Form_Main1
ON KEY ESCAPE OF FORM_MAIN1 ACTION FORM_MAIN1.RELEASE
ACTIVATE WINDOW Form_Main1
IF GetProperty( cForm, 'FocusedControl')!=cTitulo
cTrol:=GetProperty( cForm, 'FocusedControl')
DISABLE CONTROL EVENT &cTrol OF &cForm
IF EMPTY(cVar) // --> Si esta vacio me quedo donde estaba
DoMethod( cForm,cTitulo, 'SetFocus' )
lOk:=.f.
ENDIF
ENABLE CONTROL EVENT &cTrol OF &cForm
ENDIF
ENDIF
RETURN lOk