Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Undocumented feature in BTFindKeyAndRef

22 views
Skip to first unread message

Rob Roberts [TPX]

unread,
Oct 23, 2002, 7:19:20 PM10/23/02
to
John,

> Unless I'm missing something, I believe I found an undocumented feature
> (I guess you could call it a bug) in BTFindKeyAndRef. I am posting this
> just to let everyone know.

That's interesting, but I'm not sure it could be called a bug. I'd be
interested in knowing what the value of IsamError is after each of your
examples. From the documentation, I would expect that after your first
example, IsamError would end up being 10260. If it is zero instead, then I
would agree that it is a bug. (Although it could be argued that since a
UserDatRef of zero isn't actually a valid location for a data record, the
behavior of BTFindKeyAndRef is undefined in that case.)

--Rob [TPX]


Sharon Wright

unread,
Oct 23, 2002, 6:14:51 PM10/23/02
to

Hi Everyone!

Unless I'm missing something, I believe I found an undocumented feature (I
guess you could call it a bug) in BTFindKeyAndRef. I am posting this just to
let everyone know.

Here's the story.

Let's assume you have a small table with only 4 records, which have
reference numbers 1, 2, 3 and 4 and Key values "A", "B", "B" and "D",
respectively. Let's say you want to find the last record with key value "B".
The elegant way to do this is to call BTFindKeyAndRef as follows:

BTFindKeyAndRef( MyPtr, // IIsamFielBlockPtr
1, // Key number
0, // Var UserDefRef
'B', // Var UserKey
-1) ; // NotFoundDirection

Since you don't know the reference number before hand, I have been entering
"0". What I have found is that this always works if the NotFoundDirection =
1, but does not work if NotFoundDirection = -1 and UserDefRef = 0 and the
value of UserKey exactly matches the value in one or more records. The above
example will give record "A" instead of either of the "B" records. To fix
this, you simply enter BTFileLen(MyPtr) for the record number if
NotFoundDirection = -1.

Here are some more examples:

1) As stated above
BTFindKeyAndRef( MyPtr, // IIsamFielBlockPtr
1, // Key number
0, // Var UserDefRef
'B', // Var UserKey
-1) ; // NotFoundDirection
works incorrectly and gives the "A" record.


2) BTFindKeyAndRef( MyPtr, // IIsamFielBlockPtr
1, // Key number
4, // Var UserDefRef
'B', // Var UserKey
-1) ; //
NotFoundDirection
works correctly and gives the last "B" record.


3) BTFindKeyAndRef( MyPtr, // IIsamFielBlockPtr
1, // Key number
0, // Var UserDefRef
'C', // Var UserKey
-1) ; //
NotFoundDirection
works correctly and gives the last "B" record.


4) BTFindKeyAndRef( MyPtr, // IIsamFielBlockPtr
1, // Key number
0, // Var UserDefRef
'B', // Var UserKey
1) ; //
NotFoundDirection
works correctly and gives the first "B" record.


Enjoy!

-John Santmann
E-mail: jsan...@wellsoft.com


0 new messages