• Deleting a record

    From Sean Dennis@1:18/200 to All on Wednesday, September 28, 2005 22:42:50
    Hello, All!

    I'm working on a new BBS door for my system and I need it to be able to delete a record from a file. This is a typed file and only contains five fields for each record. I'm not wanting to have to read the file, remove the one record, then rewrite the file again (kinda the long way around). Any suggestions?

    Later,
    Sean

    --- FleetStreet 1.27.1
    * Origin: Outpost BBS - Johnson City, TN (1:18/200)
  • From Scott Little@3:712/848 to Sean Dennis on Thursday, September 29, 2005 21:19:20
    [ 28 Sep 05 21:42, Sean Dennis wrote to All ]


    I'm working on a new BBS door for my system and I need it to be able
    to delete a record from a file. This is a typed file and only
    contains five fields for each record. I'm not wanting to have to read
    the file, remove the one record, then rewrite the file again (kinda
    the long way around). Any suggestions?

    Have a Deleted attribute on each record. If you also want to avoid repacking the database periodically, keep an index file that maps out which records are deleted so you can reuse them (but double check anyway, ie. seek the record, read it, check it, overwrite it).

    If you know you only need to delete one record, then you can iterate over every
    subsequent record, copying it over the previous, then truncate the last record.


    -- Scott Little [fidonet#3:712/848 / sysgod@sysgod.org]

    --- GoldED+/W32 1.1.5-20050419
    * Origin: Cyberia: 100% Grade "A" mansteak baby. (3:712/848)
  • From Scott Adams@1:112/91 to Sean Dennis on Saturday, October 01, 2005 04:33:25
    Quoting Sean Dennis to All <=-


    I'm working on a new BBS door for my system and I need it to be able
    to delete a record from a file. This is a typed file and only
    contains five fields for each record. I'm not wanting to have to read
    the file, remove the one record, then rewrite the file again (kinda
    the long way around). Any suggestions?

    Theres no correct or easy way. In fact theres dozens
    of ways to handle this. Some as complex like B-Trees
    and such. Some as simple as sorting/record management
    routines. But since its a simple door. You could simply
    locate the record (SEEK) then use some code like for
    the header or stringer make it -1 or NULL or something.
    Then when the BBS closes or does maintenance at night
    It can then rewrite the file and clean out the mess.
    Course since its only 5 fields and likely only a dozen
    or so data for players? Then likely either way is
    fast and simple. But I'm sure by now folks have given
    suggestions.

    Opps. Forgot. At the maintenance or close. Simply
    read each rocord as you suggest. Skip those with the
    delete attribute (-1/NULL/"DELETE"/etc.) and bam
    its done.

    ... Mister Garibaldi !!!!! I Knoooooww....
    --- Fringe BBS
    * Origin: EWOG II - The Fringe - 904-733-1721 (1:112/91)