Comments

To edit a record, seek() to it's position, read it, then make the changes, seek() to that same record position again and write it. It will just save it over top of the old one. How you want to find it is your choice. You could ask for the question number or just display the questions one-by-one until the user sees the one they want to edit or you could include a search to find any records relating to the search.

As for deleting records, this is more intersting. You could just blank out the question line and have your program check for this (although it will add extra useless data to your file) or you could actually delete the record. To do this, open your file, rename it to a temp name, make a new file and copy every record except the one you want to delete, erase the temp file.

First thing is I would make a procedure that all it does is saves the record to a given record number. In this example, if the given record number is -1, we assume that it is a new record and add it to the end.

It is bad programming habit to leave a file open any longer than needed. So in the case of your "Add" procedure, the file is left open the whole time a user is inputting data. If this file was to be used by more than one person and a person just left their screen at the input, nobody else could use it. Also, if a computer crash happened, you could lose all of the info in the file. (Also, you were not closing the file)

Also, try to keep your capitialization on variables the same throughout. you have your record declared as 'qa', then assign it as 'QA' and have a file of type 'Qa'. I know it doesn't matter in Pascal, but it's another good programming habit to get into.

anyway can you tell me a command that can only overwrite seems if i use write(qfile,recq); in edit it just creates another record is there any command that can only overwrite the one you want to edit thanks for your help

and if i use the commands you gave me it say writeRecord is unidentified variable what should i do with this...

yup i tried it but there was an error that says writeRecord is a unknown identifier that was the error i could use the program well but that error...can you fix it what should i do with the writeRecord?

writeRecord(path, recq, -1); (writeRecord)=is unknown identifier what should i do with it?

Did you add the "PROCEDURE writeRecord(...);" from above to your code?If so, make sure that it is listed above any other procedures that call it (in this case the "Add" & the edit procedure). With Pascal a procedure that is called must have the definition come first.

AKA make sure that the writeRecord() procedure is above the Add() procedure.

The readRecord() procedure asks for the number of a record and stores just that one record in memory, no others. The writeRecord() procedure just changes the information of a record.

Think of it like a recipe box with cue cards all numbered in order.If we look at card number 16, maybe we'll see that it is a recipe for chocolate chip cookies. We don't know what any other card is, although we could look at them if we wanted. This is how our readRecord() works. We just provide a number and get back the info. If we wanted a certain recipe, we would have to "look at" or "readRecord()" all cards until we found the one we wanted.

Now that we are looking at #16 let's say that we find a mistake. We can take it out, make changes and put it back in place (our writeRecord() procedure).

Now let's say that we want to write a new card. We find out that we have 31 recipes, so we just writeRecord() to recipe card #32 (our "Add()" procedure).