Hello,
I have a question/discussion about DBSEEK(). I've started from the
different ADSCDX and DBFCDX behavior and later included Clipper tests.
#ifdef __HARBOUR__
REQUEST ADSCDX
#endif
REQUEST DBFCDX
FIELD F
FUNC main(cADS)
IF EMPTY(cADS)
RDDSETDEFAULT("DBFCDX")
ELSE
RDDSETDEFAULT("ADSCDX")
ENDIF
? VERSION(), RDDSETDEFAULT()
DBCREATE("test187", {{"F", "N", 5, 0}},, .T.)
OrdCreate("test187", "f", "F")
DBAPPEND(); F := 1
DBSEEK(10, .T., .F.)
? RECNO()
DBSEEK(10, .T., .T.)
? RECNO()
DBCLOSEALL()
RETURN 0
The code above prints:
C:\cawi32\sample\test>test187.exe
Harbour 2.0.0 (Rev. 13372) DBFCDX
2
1
C:\cawi32\sample\test>test187.exe xxx
Harbour 2.0.0 (Rev. 13372) ADSCDX
2
2
C:\cawi32\sample\test>test187.exe
Clipper (R) 5.2e Intl. (x216) (1995.02.07) DBFCDX
2
2
So, I looks like Harbour's DBFCDX is wrong and ADSCDX is OK, but my
co-worker said, that Clipper has bugs in softseek. I've tried another test:
REQUEST DBFCDX
#ifdef __HARBOUR__
REQUEST ADSCDX
#endif
FIELD F
PROC main(cADS)
IF EMPTY(cADS)
RDDSETDEFAULT("DBFCDX")
ELSE
RDDSETDEFAULT("ADSCDX")
ENDIF
? VERSION(), RDDSETDEFAULT()
DBCREATE("test188", {{"F", "N", 5, 0}},, .T.)
OrdCreate("test188", "f", "F")
DBAPPEND(); F := 1
DBAPPEND(); F := 1
DBAPPEND(); F := 3
DBAPPEND(); F := 3
DBSEEK(2, .T., .F.)
? RECNO()
DBSEEK(2, .T., .T.)
? RECNO()
DBCLOSEALL()
RETURN
It prints:
C:\cawi32\sample\test>test188.exe
Harbour 2.0.0 (Rev. 13372) DBFCDX
3
2
C:\cawi32\sample\test>test188.exe xxx
Harbour 2.0.0 (Rev. 13372) ADSCDX
2
2
C:\cawi32\sample\test>test188.exe
Clipper (R) 5.2e Intl. (x216) (1995.02.07) DBFCDX
5
5
So, we have a different behavior for all of RDD's, and I seems Clipper
ignores softseek at all.
From a printed (CL53) reference guide vol.1 page 2-315 I can read:
"<lLast> is specified as true (.T.) to seek the last occurence of the
specified key value." , but it is not clear how it works if specified
key does not exists. I can also read on the same page: "... for a soft
seek, the work area is positioned to the first record whose key value is
greater than the specified key value. If no such record exists, the work
area is positioned to LASTREC() + 1 and EOF() returns true (.T.)".
So, in the latter sample (test188) I would expect:
3
4
but not any of the above results from various tests.
*** So, how soft seek and last seek should work? ***
The question becomes even more complicated if think about DESCENT index.
Regards,
Mindaugas
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour