xsharp.eu • DBServer:OrderSkipUnique not working?
Page 1 of 1

DBServer:OrderSkipUnique not working?

Posted: Fri Sep 09, 2022 1:13 pm
by Kai
Hello everyone!

It sems that DBServer:OrderSkipUnique() is not working. I wrote the following code for testing:

METHOD ButtonTest AS VOID PASCAL
LOCAL oDBServer AS DbServer
LOCAL oTB AS TextBox

oDBServer := DbServer{"c:xsharptmppos.dbf", DBSHARED, FALSE, "DBFCDX"}
oDBServer:SetIndex("c:xsharptmppos.cdx")
oDBServer:SetOrder("TischNr")
oDBServer:GoTop()

WHILE !oDBServer:EOF
oTB := TextBox{, "test", NTrim(oDBServer:fieldget("bTischNr")) + CRLF + NTrim(oDBServer:RecNo)}
oTB:Type := BUTTONYESNO
IF oTB:Show() == BOXREPLYNO
EXIT
ENDIF

oDBServer:OrderSkipUnique()
ENDDO

oDBServer:Close()


It allways shows :
-1000
14501

The OrderSkipUnique() function does not appear to be executed.
I recreated the cdx file but it still didn't work.
The .dbf and the .cdx are in the attachments.

Regard
Kai

DBServer:OrderSkipUnique not working?

Posted: Fri Sep 09, 2022 1:40 pm
by FFF
Kai,
didn't know this method ;-)
But what do you expect. After GoTop, your TischNr is "1" - the next TischNr, which is NOT 1, is -1000, and this in record 14501. Behind this record no ofter TischNr exists. So, for my eyes, the result is correct.

BTW, wouldn't hurt to first check with and the provide a sample dbf with a bit less records ;-)

DBServer:OrderSkipUnique not working?

Posted: Fri Sep 09, 2022 1:59 pm
by Kai
Hi Karl!

Sorry for the large amont of records.

For me after GoTop() bTischNr is -1000 and not 1. The correct ascending order is -1000, -1 since -1000 is less than -1

I Expect:

GoTop() bTischNr = -1000 / EOF = false
First OrderSkipUnique() bTischNr = -1 / EOF = false
Second OrderSkipUnique() EOF = true

In VO it works like this.

Regards

Kai

DBServer:OrderSkipUnique not working?

Posted: Fri Sep 09, 2022 3:15 pm
by Chris
Hi Karl, Kai,

Indeed there's a problem here, OrderSkipUnique() fails to move to the next group of values or to eof if not one is found. Will log this for Robert to look into it and fix it, problem can be also reproduced as such:

Code: Select all

FUNCTION Start() AS VOID
LOCAL nDirection := NIL AS USUAL
LOCAL cFileName AS STRING
LOCAL n AS INT

cFileName := "c:dbfSkipUnique"

DbCreate(cFileName , {{"FLD","N",5,0}})
FErase(cFileName + ".cdx")

DbUseArea(,"DBFCDX",cFileName)
FOR n := 1 UPTO 10
	DbAppend()
	FieldPut(1, iif(n%2==0, 1 , 2))
NEXT
DbCreateIndex(cFileName, "FLD")
DbGoTop()

WHILE !Eof()
	? FieldGet(1) , RecNo()
	VoDbOrderInfo( DBOI_SKIPUNIQUE, "", NIL, REF nDirection )
ENDDO

DbCloseArea()
.

DBServer:OrderSkipUnique not working?

Posted: Fri Sep 09, 2022 3:27 pm
by FFF
Hi Kai,
sorry for the confusion, you are right, of course. To my defense, i looked in the dbf with a tool, to find out, what's in - so no SetOrder, then stopped thinking...
That's the difference between the gurus like Chris and noobs like me ;-)

DBServer:OrderSkipUnique not working?

Posted: Fri Sep 09, 2022 3:34 pm
by Chris
It's just the difference that I'm paid money to investigate things like that, so I need to persist and fully investigate what's going on ;)

DBServer:OrderSkipUnique not working?

Posted: Sat Sep 10, 2022 8:44 am
by Kai
Hi Chris!

Thanks for reporting this issue to Robert.

I found another problem with DBServer:Seek(). The lLast Parameter seems to be ignored. Can you check this please if this issue is not known yet?

Regards
Kai

DBServer:OrderSkipUnique not working?

Posted: Sat Sep 10, 2022 2:48 pm
by Chris
Hi Kai,
Kai post=23743 userid=4500 wrote: I found another problem with DBServer:Seek(). The lLast Parameter seems to be ignored. Can you check this please if this issue is not known yet?
In a small test case I wrote, this seems to work fine here. Can you please provide a sample showing the problem?

.

DBServer:OrderSkipUnique not working?

Posted: Sat Sep 10, 2022 3:15 pm
by Kai
Hi Chris!

I wanted to make a small example but for some reason it works fine for me now too.

Sorry, I really don't know why? I'll work on it and let you know when I have something new. This morning I tested it several times and it never worked, and the only thing is, that I restarted the computer after lunch.