> Hi there, I hope someone can help! I'm new to Pascal programming and
I'm
> trying to read records from a text file, then write records with
errors to
> an output file. For simplicity as I'm having problems, I've been
trying to
> write ALL records to this output file. This is the code I have:
> program WagesReport;
> type
> Employee = record
> Name: string[20];
> Shifts: char;
> TaxCode: string[4];
> Clock, Days, Hours, ExtraHours: integer
> end;
> var
> EmployeeFile, ErrorFile, PrintFile: text;
> Date, Week: integer;
> Hours, Shift: array ['A'..'B'] of real;
> Letter: 'A'..'B';
> EmpRec: Employee
> procedure OpenFiles;
> {Open the input and output files}
> begin {begin - OpenFiles}
> assign(EmployeeFile, 'EMPLOYEE.TXT');
> reset(EmployeeFile);
> assign(ErrorFile, 'ERROR.TXT');
> rewrite(ErrorFile);
> assign(PrintFile, 'PRN');
> rewrite(PrintFile)
> end; {end - OpenFiles}
> procedure Validate;
> {Validates data in Employee File}
> begin {begin - Validate}
> while not eof(EmployeeFile) do
> with EmpRec do
> begin
> readln(EmployeeFile, Name, Letter, TaxCode, Clock, Shifts,
Days,
> ExtraHours);
> writeln(ErrorFile, Name, Letter, TaxCode, Clock, Shifts, Days,
> ExtraHours)
> end;
> end; {end - Validate}
> etc etc.........
> Is the code wrong, or is it something to do with the text file? If the
> latter, can someone explain the easiest way to create a text file just
so
> that I can test the program?