Re: a few questions
- Posted by George Walters <gwalters at sc.rr.com> Jul 30, 2001
- 337 views
Irv, If I have a particular key 'abc' and it's record and I want the next record (in sorted order) it will not necessarily be db_record_key(x+1) , the next record's key. The records are not in sorted order, so the next record's key will not be the next (sorted) key. Am I understanding this correctly? And if you want to start at the beginning, you don't have a key. Do you use a key of "" to position to the beginning of the file? ..george ----- Original Message ----- From: "Irv Mullins" <irvm at ellijay.com> To: "EUforum" <EUforum at topica.com> Subject: Re: a few questions > > > In EU data base I see no way to perform a 'read next' or 'read previous' > > type function. I would like to be able to do this and get the data > elements > > out in sorted (by key) order. Is this do'able? The are apparently stored > in > > sorted order since a binary search is done with a db_find. > > The keys are stored in sorted order with the base. > To read them all, loop from 1 ... db_table_size() > To select the prev or next record, either keep a counter, > or, if you have done a lookup, and want the previous or next > record from that point: > x = db_find_key(IHaveThisKey) > if x > 0 then -- key was found, so > prevkey = db_record_key(x-1) > nextkey = db_record_key(x+1) > nextdata = db_record_data(x+1)... > > You may want to put some sanity checks on x before you try to retrieve > record numbers > less than 1 or higher than the size of the table. > > Regards, > Irv > > > > >