Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SEEK() not working as expected
Message
From
08/07/2000 17:10:18
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
SEEK() not working as expected
Miscellaneous
Thread ID:
00389870
Message ID:
00389870
Views:
47
I have some code that generates a cursor on-the-fly to populate a grid. Two indices are created on this cursor.

A separate text box provides incremental search of the grid. Some other code hooked into the .InteractiveChange of the text box steers the cursor record pointer.
Method LT2_CursorReordersDNRs builds and indexes the cursor:
LOCAL ;
	lnSelect

lnSelect = SELECT(0)

WAIT WINDOW NOWAIT "Building Indices..."

* Open tables:
USE (ALLTRIM(goApp.LT2_cLT1_DataRoot) + ALLTRIM(goApp.LT2_cYearName) + ;
	"\Reorders") IN 0 SHARED

SELECT ;
	A.Reord_No, ;
	A.CustName, ;
	PADR(ALLTRIM(B.Sch_Name) + ", " + ;
		ALLTRIM(B.Sch_City) + ", " + ;
		ALLTRIM(B.Sch_Prov) + " " + ;
		ALLTRIM(B.Sch_Phone), 70, " ") AS cSchool, ;
	A.OrdrDate ;
	FROM Reorders A ;
		INNER JOIN Schools B ;
		ON B.Sch_ID == A.Sch_ID ;
	INTO CURSOR _SearchRD

USE (DBF("_SearchRD")) ALIAS SearchRD IN 0 AGAIN

SELECT SearchRD
INDEX ON UPPER(CustName) TAG CustName
INDEX ON UPPER(cSchool + CustName) TAG cSchool

WAIT CLEAR

SELECT (lnSelect)

* Method LT2_IncrementalSearch performs the search:
LPARAMETERS ;
	tcSearchString

LOCAL ;
	lnSelect, ;
	lcOldOnError, ;
	llSoftSeekFailed, ;
	lcSearchAlias

lnSelect = SELECT(0)

DO CASE
CASE This.opgType.Value = 1
	lcSearchAlias = "SearchSD"

CASE This.opgType.Value = 2
	lcSearchAlias = "SearchRD"

CASE This.opgType.Value = 3
	lcSearchAlias = "SearchGr"

ENDCASE

SELECT (lcSearchAlias)

IF EMPTY(tcSearchString)
	GO TOP IN (lcSearchAlias)

ELSE
	<b>IF SEEK(UPPER(tcSearchString), lcSearchAlias)</b>
		* OK
		
	ELSE
		* Not found, do a soft seek to get a close record:
		lcOldOnError = ON("ERROR")
		llSoftSeekFailed = .F.
		
		ON ERROR llSoftSeekFailed = .T.
		
		GO RECNO(0) IN (lcSearchAlias)
		
		IF llSoftSeekFailed
			GO BOTTOM IN (lcSearchAlias)
		
		ENDIF
	
	ENDIF

ENDIF

* Pop the focus to the grid so the RecordMark shows properly:
=This.grdSearch.SetFocus()
=This.txtcSearchString.SetFocus()

SELECT (lnSelect)
The incremental search method supports searching in 3 cursors with a total of 5 index tags. Other controls ensure that the correct tag is active for the desired search.

Everything works perfectly fine except for searches on the CUSTNAME tag of the SearchRD cursor. For that tag, any search string fails in the SEEK() call. That is, when running in the IncrementalSearch method, the SEEK() call returns .F. when it should return .T..

Searches on its cSchool tag work perfectly. I can SUSPEND the code immediately before the SEEK() call, execute the same command in the Command window, and SEEK() works as expected.

Searches in either of the other two cursors, on any of their supported tags, work fine as well.

Both the SCHOOLS and REORDERS tables are FPDOS 2.6 free tables. I have copied the contents of the REORDERS tables out and rebuilt its indices from scratch.

WAGs, anyone?
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Next
Reply
Map
View

Click here to load this message in the networking platform