Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25583 > unrolled thread

Re: Foxpro goto command and deleted records

Started byEthan Furman <ethan@stoneleaf.us>
First post2012-07-18 10:23 -0700
Last post2012-07-18 10:23 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Foxpro goto command and deleted records Ethan Furman <ethan@stoneleaf.us> - 2012-07-18 10:23 -0700

#25583 — Re: Foxpro goto command and deleted records

FromEthan Furman <ethan@stoneleaf.us>
Date2012-07-18 10:23 -0700
SubjectRe: Foxpro goto command and deleted records
Message-ID<mailman.2274.1342631786.4697.python-list@python.org>
Ed Leafe wrote:
> On Jul 17, 2012, at 5:57 PM, Ethan Furman wrote:
> 
>> In Foxpro if you do a
>>
>> GOTO 7
>>
>> with deleted off and record 7 is deleted, the record pointer doesn't
>> move (at least in version 6).
>>
>> I don't like that.
>>
>> I see four other options:
>>
>> 0) don't move the pointer (listed for completeness)
>> 1) go to that record anyway
>> 2) go to the next undeleted record
>> 3) go to the seventh undeleted record (possibly the least practical)
>> 4) raise an exception
>>
>> Any opinions?
> 
> 	It's been many years since I fired up VFP, but the above doesn't sound correct. If you have SET DELETED OFF and the GOTO 7, the pointer should move to the 7th record, whether it is marked deleted or not. With SET DELETED ON, the pointer should not move, since 7 is not a valid record.

Your memory is good!  I typed it in wrong.

I still don't like it.  Any opinion on the other four choices?  I'm
leaning towards 1, possibly with 4 as an option:

     def goto(self, recno, raise_if_deleted=True):
         if is_deleted(self[recno)) and raise_if_deleted:
             raise DbfError(
                "Record %d is deleted and use_deleted is False" % recno)
         self._index = recno

Part of the reason I feel this is reasonable is that with my dbf module
it is possible to create an index that does /not/ include certain records:

     def ignore_deleted(record):
         if dbf.deleted(record):
             return dbf.DoNotIndex
         return dbf.recno(record)

~Ethan~

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web