Hi Chriss
I see you've defected from the QBasic Page.
Unless you've already sorted the original data file and put all the deleted records at the bottom of the file it looks as though you're killing off the data file before you've finished reading from it. This is because as soon as the program finds a deleted record it jumps to Finished: which deletes it.
Also I'm not sure where you are getting a$ from in the line IF LEFT$(a$(1), 32) = ..... Unless you're keeping a separate array of records to be deleted or putting phonedat$ into a$, I think the line should read LEFT$(phonedat$, 32) = .....
A simpler method would be to use something like this :-
OPEN oldfile FOR INPUT ACCESS READ LOCK READ WRITE AS #1
OPEN newfile FOR OUTPUT ACCESS WRITE LOCK READ WRITE AS #2
DO
LINE INPUT #1, InRec$
IF LEFT$(InRec$, 7) <> "DELETED" THEN PRINT #2, InRec$
LOOP UNTIL EOF(1)
CLOSE
KILL oldfile
NAME newfile AS oldfile
Also some general programming notes. These have been mentioned before in this forum, so I don't really want to start a new thread about them, but I'll happily take on all comers if they want to.
Personally I can't stand single letter variable names, like A$ for example, not even for simple things. I prefer names like "Count" for even simple loop counters. I spend a lot of my time either debugging or updating programs where sometimes the original programmer has left the company I work for. It sometimes takes forever tying to work out what variables do, so please try and get into the habit of making the variable names meaningful.
Another good one is the argument about indents, indents really should be used all the time for loops etc. It makes life so much easier. I know this forum doesn't show them in the posts, so please don't think I'm getting at you personally.
And another thing, I don't know what the first 32 characters of the record used to contain, but a simpler method is to keep a field especially to show whether a record has been marked for deletion. This can be a character field, numeric or string, it doesn't matter. The reason for this is that then you can give the user the choice of undeleting the record before it is written to the new file. If those first 32 characters were, say for example, someones name in the phone list then it can't be undeleted unless the user re-enters the information that was overwritten.
Sorry about the long reply, but I'm a database programmer and deal with these things daily. Usually though in VB, FoxPro, SQL etc. not QBasic (but it has been known for me to). I know I keep mentioning it in my posts, but my own website at
members.lycos.co.uk/brisray/ has a whole bunch of stuff about DB programming, sorting and matching records, adding sequence numbers etc. etc.
As a newbie, this looks like some sort of project you're doing. A good thing to remember about programming is that although classed as a science it's really an art. There are as many ways of writng code and as there are programmers. So long as it works it's right!!!
Good luck with the project. Everyone is this forum was there once - and some of us are STILL learning.
Regards
Ray