|
From: Ralph on 4 May 2008 10:35 <realvampirelestat(a)yahoo.com> wrote in message news:7e63a964-3f94-42d1-b3a7-83f8e38b7f96(a)25g2000hsx.googlegroups.com... > I'm writing a payroll program for a school project and I've gotten it > to write new information (Updated Employee info) to the .DAT file but > I don't know how to remove the old information from the file. Thank > you for your help Super simple method: Assuming you have something like this .. File Header Record1 Record2 Record3 Record4 .... Take a key from the granddaddy of them all - xBase (dbf) and create a field called "Deleted". Whenever the record isn't needed any longer set this field to True. During normal processing ignore any records that have this field set. Then periodically run a "Pack" on the .DAT file. 1) Create a blank temp file 2) Open the Dat file and write each record that doesn't have that field set to the temp file. 3) Close the .Data file 4) Delete it 5) Rename the temp file to your .DAT file. We can get fancier, but this should work well with a school project. -ralph
|
Pages: 1 Prev: Interfacing with a device driver (specifically USB GPS) Next: Create chm file |