Cursor pointer (the current record)

Bob Sneidar bobs at twft.com
Tue Dec 23 12:37:19 EST 2008


Hi all.

I find this odd. When I first get a cursor and then check the  
condition of beginning of file, I get true. The record number is 0.  
Okay. But when I get the data from the cursor for that record, I do  
not get null values I get the data from the first record. Hmmm....  
alright. So I go to the first record in the cursor. The record number  
is still ZERO!

Okay, so then I go to the first record then go previous. The record is  
still zero and data is the data in the first record. I go next after  
that and I am still at record zero, and the data is the same as before!

A similar thing happens on the last record. I get eof true when on the  
last record. I can live with this, but does that mean that when I  
return a record number of 364 I am actually at record 365?? What an  
odd way of doing things if so. I cannot very well present to my user  
that they are on record zero. I can always add one for display  
purposes but keep my real record number as it is, I just find this  
behavior very odd.

A BOF condition is usually true if a record pointer is one record  
BEFORE the first record. And EOF condition is usually true if the  
pointer is on a record one PAST the last one. That way I can check for  
(BOF or EOF) and know I am pointed at a valid record. I can also  
continue a loop until EOF and know that I have no more records to  
process, NOT that I have one more to go!

FUNCTION checkitout theRecord
     put revdb_movefirst(mCursor) into mres
     put revCurrentRecord(mcursor) into mrecord -- returns 0!
     put revdb_movelast(mCursor) into mres
     put revCurrentRecord(mcursor) into mrecord -- returns one less  
than the record count
     put revdb_movenext(mCursor) into mres
     put revCurrentRecord(mcursor) into mrecord -- returns the same  
thing
END checkitout

Anyone else find this odd?

Bob Sneidar
IT Manager
Logos Management
Calvary Chapel CM




More information about the use-livecode mailing list