At 4:12 PM -0800 3/2/99, Bryan Nystrom wrote:
>> I'm expecting you're getting index 7 in your second case, since
>> DmSeekRecordInCategory() starting at index 4 (even) and seeking forward
>> 1 in the odd category will first find the next odd category record (5)
>> and then seek forward 1 from there (7).
>>
>
>Actually, I'm getting a return code of 0 for either direction when I'm "off
>Category". That is what doesn't make sense to me.

Return code?  The return code is an error indicator, and you should
generally always get 0, because that means no error.  The index pointer
(2nd argument) gets updated and is how the new index is returned.
Hopefully you're not saying the index is always 0?

The problem is as John said -- the code actually starts comparing at the
current record, and decrements the offset for each match.  So if you start
at a match, passing 1 as the offset works because it decrements the counter
on the (current) match, then at the next match the counter is 0 so it gets
returned.

But if you start on a non-match, you're really "in-between" matching
records, and you don't decrement the counter right away.  In this case, if
you pass 0 as the offset you'll get the nearest matching record in the
specified direction.  ...of course, if you're on a match and you pass 0 you
get the same record back.

Anyway, now you should be able to create a few lines of code that do what
you really want.

I agree that the behavior a little non-intuitive, but it's how the code
works.  :)

                                --Bob


Reply via email to