1. a few questions
- Posted by George Walters <gwalters at sc.rr.com> Jul 30, 2001
- 379 views
Can someone explain 'short circuit' to me (or give me an example). I find no reference to it in the manual.. 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. Can someone explain the search path. It seems to open files and data bases that the entire path has to be specified.
2. Re: a few questions
- Posted by Irv Mullins <irvm at ellijay.com> Jul 30, 2001
- 380 views
----- Original Message ----- From: George Walters <gwalters at sc.rr.com> Subject: a few questions > > Can someone explain 'short circuit' to me (or give me an example). I find no > reference to it in the manual.. Suppose you have the code: if a = 1 and foo(bar) = 3 then do something Supposing a did not equal 1, then Euphoria would not bother to look at foo(), so foo() would not be executed. Sometimes you might be expecting foo() to do some work besides just returning a value to compare, and in this case, that work wouldn't get done. Hence the warning. Regards, Irv
3. Re: a few questions
- Posted by Irv Mullins <irvm at ellijay.com> Jul 30, 2001
- 384 views
> 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
4. Re: a few questions
- Posted by George Walters <gwalters at sc.rr.com> Jul 30, 2001
- 358 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 > > > > >
5. Re: a few questions
- Posted by Irv Mullins <irvm at ellijay.com> Jul 30, 2001
- 372 views
On Monday 30 July 2001 09:22, George Walters wrote: > > 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? No. The record keys are always stored sorted. If you put in a random list of names: Zorro Bubba Norton Chuck Al Then they will be stored in the database as: 1. Al 2.. Bubba 3. Chuck 4. Norton 5. Zorro Therefore, to start at the beginning of the list, retrieve record 1, For the list above, db_record_key(1) would return Al db_record_key(db_table_size()) would return Zorro. Regards, Irv
6. Re: a few questions
- Posted by George Walters <gwalters at sc.rr.com> Jul 30, 2001
- 380 views
I understand now... I think the doc is misleading... it says "Return the key portion of record number i in the current table" and the key of record x+1 is not the same as key(x+1).. It should probably say "Return the i'th key in the current table". thanks... ..george ----- Original Message ----- From: "Irv Mullins" <irvm at ellijay.com> To: "EUforum" <EUforum at topica.com> Subject: Re: a few questions > > On Monday 30 July 2001 09:22, George Walters wrote: > > > > 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? > > No. The record keys are always stored sorted. > If you put in a random list of names: > Zorro > Bubba > Norton > Chuck > Al > > Then they will be stored in the database as: > 1. Al > 2.. Bubba > 3. Chuck > 4. Norton > 5. Zorro > > Therefore, to start at the beginning of the list, retrieve record 1, > For the list above, db_record_key(1) would return Al > db_record_key(db_table_size()) would return Zorro. > > Regards, > Irv > > > > >