Delete record in Random Access File


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Delete record in Random Access File

  1. #1
    Chris Guest

    Delete record in Random Access File


    At a point in my project, you can view successive records in a random access
    file by hitting the "Next Record" button, based on the following code:

    Private Sub cmdNext_Click()
    currentrecord = currentrecord + 1
    displayrecord currentrecord, Me
    End Sub

    You can also go backward in the list after record #1 by clicking on "Previous
    Record."

    I need a way to let the user delete the currently displayed record if they
    choose. Say they are viewing record #2 out of 7 records and want to delete
    it. After they click "Delete Record," there should be 6 total records left
    and they are back viewing record #1, ready to scroll through them again.

    What would be the best way to do that?

    Chris Bowen

  2. #2
    dnagel Guest

    Re: Delete record in Random Access File

    The quickest way might be to add a byte to the record that you use
    as a status indicator. If they delete the record, set the indifator to
    (arbitrary value) 0. When you create one, set it to (arbitrary value again)
    1. When moving to the next record, read it in and check the byte, if its 0
    then move to the next record.

    Supply a function that allows them to compact the database. This
    will walk the records and create a new file with only records that
    have the byte set to 1. then close both files and kill the original and
    rename the new one to the old file name.

    This will prove to be the quickest means for dealing with record deletion
    at runtime.

    D.

    "Chris" <cbowen@petersontools.com> wrote in message
    news:3c7d0870$1@10.1.10.29...
    >
    > At a point in my project, you can view successive records in a random

    access
    > file by hitting the "Next Record" button, based on the following code:
    >
    > Private Sub cmdNext_Click()
    > currentrecord = currentrecord + 1
    > displayrecord currentrecord, Me
    > End Sub
    >
    > You can also go backward in the list after record #1 by clicking on

    "Previous
    > Record."
    >
    > I need a way to let the user delete the currently displayed record if they
    > choose. Say they are viewing record #2 out of 7 records and want to delete
    > it. After they click "Delete Record," there should be 6 total records left
    > and they are back viewing record #1, ready to scroll through them again.
    >
    > What would be the best way to do that?
    >
    > Chris Bowen




  3. #3
    dnagel Guest

    Re: Delete record in Random Access File

    This also has an added bonus of allowing Un-Delete prior to compaction.

    D.

    "dnagel" <GrandNagel@hotmail.com> wrote in message
    news:3c7d29ab@10.1.10.29...
    > The quickest way might be to add a byte to the record that you use
    > as a status indicator. If they delete the record, set the indifator to
    > (arbitrary value) 0. When you create one, set it to (arbitrary value

    again)
    > 1. When moving to the next record, read it in and check the byte, if its

    0
    > then move to the next record.
    >
    > Supply a function that allows them to compact the database. This
    > will walk the records and create a new file with only records that
    > have the byte set to 1. then close both files and kill the original and
    > rename the new one to the old file name.
    >
    > This will prove to be the quickest means for dealing with record deletion
    > at runtime.
    >
    > D.
    >
    > "Chris" <cbowen@petersontools.com> wrote in message
    > news:3c7d0870$1@10.1.10.29...
    > >
    > > At a point in my project, you can view successive records in a random

    > access
    > > file by hitting the "Next Record" button, based on the following code:
    > >
    > > Private Sub cmdNext_Click()
    > > currentrecord = currentrecord + 1
    > > displayrecord currentrecord, Me
    > > End Sub
    > >
    > > You can also go backward in the list after record #1 by clicking on

    > "Previous
    > > Record."
    > >
    > > I need a way to let the user delete the currently displayed record if

    they
    > > choose. Say they are viewing record #2 out of 7 records and want to

    delete
    > > it. After they click "Delete Record," there should be 6 total records

    left
    > > and they are back viewing record #1, ready to scroll through them again.
    > >
    > > What would be the best way to do that?
    > >
    > > Chris Bowen

    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center