Is record in index ??

This forum is meant for questions and discussions about the X# language and tools
Post Reply
DanielFliff

Is record in index ??

Post by DanielFliff »

How can I efficiently determine if a specific record exists in an index using XSharp? Are there any built-in functions or methods available for this purpose?
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Is record in index ??

Post by Chris »

Hi Daniel,

What do you mean by "index"?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ecos
Posts: 103
Joined: Tue Nov 10, 2015 6:49 am
Location: Germany

Re: Is record in index ??

Post by ecos »

Hi Daniel, Chris,

see my post
https://www.xsharp.eu/forum/topic/3603

Karl
ecos
Posts: 103
Joined: Tue Nov 10, 2015 6:49 am
Location: Germany

Re: Is record in index ??

Post by ecos »

BTW,

here is my solution which seems to work

METHOD IsRecordInOrder(nRecno,nOrder) // class MyDBServer inherit DBServer
LOCAL lOk AS LOGIC
LOCAL uTop AS USUAL
LOCAL uBottom AS USUAL
LOCAL uValue AS USUAL
LOCAL nOldRec AS DWORD
LOCAL nOldOrder AS DWORD

Default(@nRecno,0)
Default(@nOrder,0)

IF nRecno > 0
nOldRec := SELF:Recno
SELF:goto(nRecno)
ENDIF
IF nOrder > 0
nOldOrder := SELF:orderinfo(DBOI_NUMBER)
SELF:setorder(nOrder)
ENDIF

BEGIN SEQUENCE

// Index-Bedingung
IF SELF:orderinfo(DBOI_ISCOND)
IF !Evaluate(SELF:orderinfo(DBOI_CONDITION))
BREAK
ENDIF
ENDIF

// Scope
uTop := SELF:orderinfo(DBOI_SCOPETOP)
uBottom := SELF:orderinfo(DBOI_SCOPEBOTTOM)

IF !Empty(uTop) .OR. !Empty(uBottom)
uValue := SELF:Orderkeyval
IF SELF:Orderdescend()
IF !Empty(uTop)
IF uValue > uTop
BREAK
ENDIF
ENDIF
IF !Empty(uBottom)
IF uValue < uBottom
BREAK
ENDIF
ENDIF
ELSE
IF !Empty(uTop)
IF uValue < uTop
BREAK
ENDIF
ENDIF
IF !Empty(uBottom)
IF uValue > uBottom
BREAK
ENDIF
ENDIF
ENDIF
ENDIF

lOk := TRUE

END SEQUENCE

IF nOrder > 0
SELF:setorder(nOldOrder)
ENDIF
IF nRecno > 0
SELF:goto(nOldRec)
ENDIF

RETURN lOk
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Re: Is record in index ??

Post by FFF »

Probably i miss the obvious - but why not doing a "Seek" in the order?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
ecos
Posts: 103
Joined: Tue Nov 10, 2015 6:49 am
Location: Germany

Re: Is record in index ??

Post by ecos »

Karl,

because the indexkey might not be unique

Karl
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Is record in index ??

Post by Chris »

Ah, I was missing the obvious, was working on some help advanced topics and was thinking about the record type in c# and index in an array :)
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply