Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popups causing VFP6 application to freeze / hang 2

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
141
GB
Hi All

I have a VFP6 application EXE that seems to freeze / hang or perhaps lose focus after an ACTIVATE POPUP command.

This is an inconsistent problem. It doesn't happen all of the time or always at the same popup. The number of items in the popup lists can be less than 10 or as many as 50+

Popup lists are used for validation or assisting on full screens that have been written with @..SAY..GET and READ instructions (this was written in FOX!) AND also from smaller prompt windows displayed over a grid form with command buttons. The problem can occur in any type of screen.

The user will type a few characters, press enter and the validation process displays a popup of potential choices. Once the popup displays, the application fails to recognize any key strokes (arrow keys etc)

The last time this happened, I asked the user to click onto the VFP screen in case VFP had lost the focus. The cursor changed from an eggtimer to a double ended arrow, the popup cleared but the software stopped responding.

Every time this type of problem occurs, they have to "end task" the application. This has been an intermittent problem for a year and I must get it sorted out.

I have considered taking out the popups and using combo boxes but this would need a list of 10,000+ items in one of the routines.

I need to find out what is causing the problem, rather than start a messy workaround.

The system is currently on an XP computer, but I cannot reproduce the behaviour on my own XP or Win98 pc. The problem persisted even when the client's hardware was changed.

I don't think it is caused by antivirus software scanning the DBFs or interrupting some other way. But I'm not 100% sure. They are using AVG.

Has anyone seen this type of behaviour before or know anything that could cause it?

Thanks

Karen

PS Sorry about the lengthy thread - I am stuck on this one!

 
The only time I have seen anything close to this is when I placed filters on very large tables.


David W. Grewe Dave
 
Thanks Dave. I will have a look at the filtering to see how it may have changed.

The software is only in its second year with this client, so the files are still pretty small.

What I don't understand is why it has run perfectly well at other sites - it's just this one that has the problems.
 
How are the Popups populated...i.e. Is it a filter or a select Statement?
Like Dave said; filtering is and has been a problem (IMO).

If its a select statement, and you say the tables are not that large, are they indexed properly and you are not processing blank records...
May be a good idea to post the Popup Code.
 
The popups are built in a DO WHILE having defined the popup and then using DEFINE BAR... within the loop.

Where possible SCAN is used, but no filters on the lookup files for the popups.

For example, the user enters the first 2 or 3 chars of a code and then the program builds the list of potential matches.

This starts with a seek on the file and works while the index key matches. The two main popups come from files of up to 2500/3000 records, from files that are already open and are not being constantly modified.

The original programs were written in FoxPro 2.0, a long time before I started using SELECT statements to populate lists etc.

I can change the creation of the popups. But it is only when the popup is displayed that the app freezes up. It just show the popup list and then you can't scroll or escape or anything.

I guess it is something to do with memory maybe. But the problem can occur with a popup of just ten items.
 
Karen,

The two main popups come from files of up to 2500/3000 records

That shouldn't cause a problem. But why don't you try it with a much smaller file (say 200 records), just to see what happens. That way, you'll know whether it's a performance issue, or something else.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I am guessing here... I dont think its a memory problem as a Do While/Scan will not hog memory.
I am assuming, the scan/Do while is in the interactive event of the textbox (where the user enters the text)... This may slow it down, unless you are using a Seek then a Scan while..., as otherwise it has to run through the whole table... Why not use an auto-complete textbox?
If you click my name and check out the F&Q, there is a good example you could modify to suit your needs.
Will try to reproduce this problem and keep you posted.
Sorry nothing else comes to mind...
 
Do not know if this will help you , but
Here is some sample code I used back in the FoxBase days to popup a menu from a table. (Sneezed for an hour from all the dust I blow off it. Date written removed to protect my age.)

Instead of using the Define BAR it uses a field name, This may stop your problem.
I do remember you had to end the menu with a call to another procedure or the system seemed to lockup. It was not, it was just waiting to exit the menu.

hope it helps

Code:
public P_Fname
.......
..code block to create the a table with records 
........

P_Fname = " "
DEFINE POPUP popupmenu FROM P_Row,P_Clm PROMPT FIELD EVAL(P_ShowFld) SCROLL SHADOW
ON SELECTION POPUP popupmenu DO PopClose WITH POPUP(), PROMPT(), P_Fname
DO WHILE EMPTY(P_Fname)
	ACTIVATE POPUP popupmenu
	DO CASE
	CASE LASTKEY() = 27
		P_Fname = " "
		EXIT
	CASE EMPTY(P_Fname) .AND. P_Empty = .F.
		P_Fname = " "
		EXIT
	ENDCASE

	RELEASE POPUP popupmenu
	SELECT (P_Dbf)
	P_Fname = EVAL(P_RtnFld)
	ON KEY LABEL RIGHTMOUSE
	ON KEY LABEL ENTER
ENDDO
.....
code block
.......

*/***************************************************************************
*# Popup Menu Close procedure
*/Program   : Procedure PopClose
*/System    : Fox Library 
*/WARNING - This Routine must and can only be called as a Procedure to end a popup menu
*/Purpose   : Closes Any Popup Menu opened by this program and return the value selected.
*/Syntax    : On Selection Popup popupmenu do PopClose with popup(),Prompt(),MemvarToChange
*/Returns   : MemVarToChange
*/Parameter : mpopup,mprompt,MemvarToChange
*/Default   : Nothing
*/Requires  : Nothing
*/Changes   : Alters the contents of the string MemvarToChange that is passed to it as a globial
*/Calls     : Nothing
*/Version   : 1.0
*/Dated     :
*/Written By: David W. Grewe
*/***************************************************************************
*& Menus - Popup
*/***************************************************************************
*/ Record Of Change
*/
*/***************************************************************************
parameter MPOPUP,MPROMPT,P_FNAME
P_FNAME = prompt()
deactivate popup POPUPMENU
*release popup POPUPMENU
return P_FNAME


David W. Grewe Dave
 
One of the popups is a list of frequently used text entries, to save retyping. The file only has 35 records - each with a 50 character text field. The popup is called from an ON KEY LABEL press during one update routine. Even this one can freeze the system.

Where a popup is used for displaying potential matches the code could be as follows. Here is the prompt:
Code:
@  2, 2 SAY 'Reg No'
@  2,12 GET mregno PICTURE REPL('!',10) VALID vreg(mregno) ;
	ERROR 'Enter part or full Reg no'+CHR(13)+CHR(13)+;
	'Select vehicle from list using'+CHR(13)+;
	'the mouse or enter key.'
READ MODAL
Here is the function for the popup code:
Code:
FUNCTION vreg
  PARAMETER mreg
  IF LEN(TRIM(mreg)) = 0
    RETURN .T.
  ENDIF
  SELECT vehicles
  SEEK TRIM(mreg)
  IF .NOT. FOUND()
    SELECT jobs
    RETURN .F.
  ENDIF
  DEFINE POPUP reg FROM 6,5 COLOR SCHEME 5 SCROLL FONT &mpopfont ;
    TITLE 'SELECT A VEHICLE'
  STORE 0 TO mc
  DO WHILE regno=TRIM(mreg) .AND. .NOT. EOF()
    STORE mc+1 TO mc
    DEFINE BAR mc OF reg PROMPT regno+' '+make+' '+model+' '+accountno
    SKIP
  ENDDO
  IF mc # 0
    ON SELECTION POPUP reg DO regload WITH PROMPT()
    ACTIVATE POPUP reg
  ENDIF
  * etc....
The freeze up occurs once a popup is displayed. Not consistently though. It can be fine for days or weeks at a time.

I'll work through each program again. There must be something else in there causing these problems.
This system did make use of function keys for fast text entries. There is still PUSH KEY, ON KEY LABEL clearing and then POP KEY code in place around some of the popup activation. E.G:
Code:
PUSH KEY
DO _offkey		&& proc to clear specific ON KEY LABEL instructions
ACTIVATE POPUP textkey
POP KEY
Could this be a part of the problem? The popup has been built and then the keys are saved to a stack. The popup displays and it freezes. I can get rid of PUSH KEY / POP KEY and have UDFs set and clear the ON KEY LABELs.


Thank you all for your help on this. I like the code solutions suggested. I will try them out later on.

Please let me know if you can see problems in any of the above.

Karen
 
Karen,
I do not see anything wrong.

As a rule, anytime I remap keys I clear the mapping as soon as I can or at the end of the procedure that remapped them. With the spped of computer nowdays, if I need them in a different procedure I remap them again.

If you have to rewrite the code, I suggest you leave the Fox world behind and go to a combo box.

Mike,
1988

David W. Grewe Dave
 
Dave

I tried out your code for building a popup from a table. I chose a table with 10700 records and it was instant. Thank you for the pointer.

Is it OK if I re-use this code to a degree?

I'm self taught and started by being thrown into modifying old DBase and mfoxplus programs. 18 years later I am still learning as I go along. (The prospect of snuggling up with a computer manual or developers guide was never appealing enough!)


I'm going to carry on with this and change the popups. I've used combo boxes from variables and arrays, and from a SELECT statement with potential for up to 900 records.

If I use a combo box for the reg no selection, there would be at least 2500 items in the combo list. This particular combo also has to have four columns.

Is that likely to cause other problems? Is there a sensible limit for a combo box?

Karen



 
Imaginecorp,

Your FAQ for the Interactive Text Box looks great.

What is Icase() in the InteractiveChange procedure? Is it like IIF() ? I am using VFP6.

Thanks

Karen

 
Hello Karen;
Yes Icase() is similar to an "extended" IIF(). It was introduced in VFP8. Just change Icase() to either:
do case... endcase or an IIF().
Though you can, I definately would not put 900-2500 items in a combobox. If you have to, I had posted an auto-complete Combobox as well, cannot remember in which thread, but will rewrite it for you if needed.
Regarding the popup problem:
what does "DO regload" do, coulds this be what is freezing the app as it may sometimes get into a never ending loop based on some uncommon criteria?
How can "regno=TRIM(mreg)" ever be true, a full value = a partial value, I am assuming "regno" is a field




 
Hi

Here is the regload function
Code:
PROCEDURE regload
  PARAMETER mprompt
  STORE SUBSTR(mprompt,1,10) TO mregno, mreg
  SEEK mregno
  SELECT jobs
  DEACTIVATE POPUP
  RETURN

The user doesn't even get to select from the popup. It just displays then stops responding. You can't escape, scroll or select.

I agree about the combo box. I want to keep the lists small. That's the point of the user entering the first few characters, to limit the popup.

I'll try using the suggestion from Dave. If I do it right I can use the index and a filter and Rushmore will help speed it up.

There are only six programs to make changes in. I'll see how that handles at the client end.

Thanks again
 
I would definitely follow Dave's excellent example, but if you notice he has a release (its commented out), you do not. Would that not create multiple popups? Something to check...
Good luck

 
Hello Karen;
Rather than a popup or a combobobox with 900-2500 records, here is another way. As you are using VFP6 this should work. Its been a long, long time since I used @Say & @Gets and I am very rusty so you will have to rewrite this to suit your needs. One year is too long so we better get this working {G}
I have used the Northwind customers table.
Code:
Clear
If Select("customers") > 0
	Select customers
Else
	Select 0
	Use Home()+"\samples\northwind\customers.dbf" Shared
Endif
Set Order To Tag Customerid


mregno = ""
@  2, 2 Say 'Reg No'
@  2,12 Get mregno Picture Repl('!',50) Valid vreg(mregno)
Read Modal


Procedure vreg(pregno)
	Select customers
	If Seek(pregno)
		Return
	Endif
	=Messagebox(Alltrim(pregno) + ' is not found'+Chr(13)+;
		'Select vehicle from list using the mouse or enter key.',16,"Registration Number")
	cValue = ""
	Do Form karen WITH Alltrim(pregno) To cValue
	If !Empty(cValue)
		mregno = cValue
		@  2,12 Say mregno
	Endif
	Use In customers
Endproc
Now the form instead of a popup:
Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (c:\imaginecorp\karen.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   05/18/07 08:07:02 PM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 283
	Width = 199
	DoCreate = .T.
	Caption = "Vehical #..."
	WindowType = 1
	Name = "Form1"


	ADD OBJECT list1 AS listbox WITH ;
		Height = 197, ;
		Left = 8, ;
		Top = 62, ;
		Width = 186, ;
		Name = "List1"


	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Double Click to Select", ;
		Height = 17, ;
		Left = 38, ;
		Top = 267, ;
		Width = 122, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		WordWrap = .T., ;
		Caption = "Type the first few characters to find the Regestration number you are looking for:", ;
		Height = 49, ;
		Left = 12, ;
		Top = 8, ;
		Width = 181, ;
		Name = "Label2"


	PROCEDURE Init
		Lparameters pValue
		cLen = Len(pValue)
		With This
			.Left = _Screen.Width - This.Width - 10
			.Top = 10
			.AddProperty("returnvalue","")
		Endwith
		Select customers.customerid ;
			FROM customers ;
			WHERE Substr(customers.customerid,1,cLen) = pValue ;
			INTO Cursor custcursor
		With This.list1
			.RowSource = "custcursor.Customerid"
			.RowSourceType = 6
			.Value = .TopIndex
		Endwith
	ENDPROC


	PROCEDURE Unload
		RETURN this.returnvalue
	ENDPROC


	PROCEDURE list1.DblClick
		thisform.returnvalue = ALLTRIM(custcursor.Customerid)
		thisform.release
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
 
Karen,
As I was looking through my library of old 2.6 routines and walking down memory lane, I found this code.
It actually works in VFP Still.

It assumes the table you want to do the lookup in is the current waork area.
Pass it the row & Column where you want the left corner of the window to be, The name of the Field you want the value from, The name of the field to search, (Can be the same) and the index name.

It displays a list of matchs as the user types in a value.

HAve fun with it. It it helps it's yours to use.
Code:
*/***************************************************************************
*#Show Results of Seek as user types it in
*/Program   : function ShowSeek
*/System    : fox library
*/Purpose   : Show the results of a seek on a STRING as it is typed in
*/Syntax    : string = ShowSeek(Row,Clm,Field1,Field2,Field3)
*/Returns   : String  - The contents of the database field
*/Parameter : Row - Integer - The screen row where the results is to be
*/          : Clm - Integer - The screen column where the results is to be
*/          : Return - Char - The DBF Field value to be returned
*/          : Field  - Char - The DBF Field to be searched
*/          : TAg    - Char - The CDX tag name
*/          : logical - Show - Do you want the results to show on the screen
*/Defaults  : none
*/Requires  : Nothing
*/Changes   : Nothing
*/Calls     : Nothing
*/Version   :
*/Dated     :
*/Written By:
*/***************************************************************************
*& Record Handling
*/***************************************************************************
*/ Record Of Change
*/
*/***************************************************************************
PARAMETERS P_Row, P_Clm, P_Return, P_Field, P_CdxTag, P_Show
PRIVATE P_Row, P_Clm, P_Return, P_Field, P_CdxTag
PRIVATE L_Para, L_Count,L_Lookup,L_Key,L_Char,L_Size, showseek

L_Para = PARAMETERS()
P_Row  = IIF(L_Para<1 or VARTYPE(P_Row)="N",P_ROW,0)
P_Clm  = IIF(L_Para<2 or VARTYPE(P_Clm)="N",P_Clm,0)
P_Return=ALLTRIM(UPPER(IIF(L_Para<3 or VARTYPE(P_Return)="C",P_Return,FIELD(1))))
P_Field =ALLTRIM(UPPER(IIF(L_Para<4 or VARTYPE(P_Field) ="C",P_Field ,TAG(SELECT()))))
P_CdxTag=ALLTRIM(UPPER(IIF(L_Para<5 or VARTYPE(P_CdxTAg)="C",P_CdxTag,TAG(SELECT()))))
P_Show  =IIF(L_Para<6 or VARTYPE(P_Show)<>"L",.f.,.t.)
L_Size   = FSIZE(P_Field)
L_Size   = MAX(L_Size * 1.5 , L_Size + 20)
C_ESCAPE=SET("ESCAPE")
SET ESCAPE OFF
*
IF P_Show
	DEFINE WINDOW SHOWSEEK1 FROM P_Row , P_Clm TO SROWS() , P_Clm + L_Size ;
		SYSTEM NOCLOSE NOFLOAT NOGROW NOZOOM FONT "Arial" , 8
	DEFINE WINDOW SHOWSEEK2 FROM 2 , 0 TO WROWS() , WCOLS() ;
		HALFHEIGHT SYSTEM NOCLOSE NOFLOAT NOGROW NOZOOM IN SHOWSEEK1  FONT "Arial",8
ENDIF
SET ORDER TO &P_CdxTag
DO WHILE .T.
	L_Count = 0
	L_Lookup = ""
	GOTO TOP
	SET CONSOLE OFF

	DO WHILE L_Count < L_Size
		IF P_Show
			ACTIVATE WINDOW SHOWSEEK1 SAME
			@ 0 , 0 SAY "Enter " + ALLTRIM(P_Field) + " To Find"
		ENDIF

		@ IIF(P_Show , P_Row + 1 , P_Row) , P_Clm SAY L_Lookup
		L_Key = INKEY()

		DO CASE
		CASE L_Key = 13 .AND. L_Count > 0
			EXIT
		CASE L_Key = 127 .OR. L_Key = 19
			L_Lookup = SUBSTR(L_Lookup,1,(LEN(L_Lookup)-1))
			L_Count  = L_Count -1
			LOOP
		CASE L_Key < 32 .OR. L_Key > 122
			LOOP
		ENDCASE

		L_Char   = CHR(L_Key)
		L_Lookup = L_Lookup + L_Char
		showseek = LOOKUP(&P_Return , L_Lookup , &P_Field , P_CdxTag)
		@ IIF(P_Show , P_Row+1 , P_Row) , P_Clm SAY &P_Field
		@ IIF(P_Show , P_Row+1 , P_Row) , P_Clm SAY L_Lookup
		L_Count = L_Count + 1
		IF P_Show
			IF EOF()
				HIDE WINDOW SHOWSEEK2
			ELSE
				SEEK L_Lookup
				ACTIVATE WINDOW SHOWSEEK2
				BROWSE FIELDS &P_Field NOWAIT NOEDIT NOAPPEND NOMENU IN WINDOW SHOWSEEK2
			ENDIF
		ENDIF
	ENDDO
*
	IF EOF()
		GO TOP
		IF MESSAGEBOX("Item " + L_Lookup +CHR(13)+ ", Not Located. Try Again?" , 20 , '') = 7
			showseek = ""
			EXIT
		ENDIF
	ELSE
		EXIT
	ENDIF
ENDDO
*
SET ESCAPE &C_ESCAPE
RELEASE P_Row, P_Clm, P_Field, P_Return, P_CdxTag
RELEASE L_Count,L_Key,L_Char,L_Size, L_Lookup
RELEASE WINDOW SHOWSEEK2
RELEASE WINDOW SHOWSEEK1
RETURN showseek

David W. Grewe Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top