Im using turbo pascal; and am using a text file to store data.
I uploaded the whole thing because its starting to get a little roomy, but here is a procedure im having trouble with:
writeln('Please enter new employees identification number: '); readln(temp_id); writeln(EmployeeFile, temp_id); writeln; writeln('Please enter employees name: '); readln(newspaper[temp_id].employee); writeln(EmployeeFile, newspaper[temp_id].employee); writeln; clearfile;
writeln('Are these details correct? [Y/N]');
if (decision = 'y') or (decision = 'Y') then
else if (decision = 'n') OR (decision = 'N') then
writeln('Invalid input. Employee not saved.');
This works but its got a lot of bugs in it, is there a way i can get the id number to automatically increase by one from the previous id number in the text file?[/quote]
You could either save your ID or determine the highest one used to date. Since you're using a text file, it could be saved by itself in the first line where you could find it easily. Be sure to write it back again at the end of the session.
As for the rest, it looks OK, but [I]clearFile[/I] seems to be something from your code. What does it do? Also, it looks like you are using an array named [I]newspaper [/I]and you're saving the employee name there indexed on the [I]temp_id.[/I] Is that correct? Why are you doing that?
Anyway, with all that in mind, I can ...