I am doing an exercise we got in school and I am stucked at the point when I think everything is correct, but obviously is not :-).
Target: Make a very simple pascal program, which opens a text file with three variables(name, sex, salary) and returns the highest women salary.
I have the following:
Program salaries; uses crt; var F:text;max,salary:word;name:string;sex:0..1; begin max:=0; assign(F,'C:\FPC\2.4.0\bin\i386-win32\salary.txt');reset(F); repeat readln(F,name,sex,salary); if (sex=1) and (salary>max) then max:=salary; until eof(F); clrscr;close(F); writeln; writeln('The highest ladies salary is: ',max); writeln('Press ENTER for exit.'); readln; end.
and text file salary.txt has following content:
Peter 0 3500
Helena 1 2000
John 0 0
Natalia 1 7000
Frank 0 7100
When trying to compile this in FreePascal, there are no errors, but once I run the program, I get exitcode 106. Could you please look at it and advise what should I change?
And another question, how to write it in order to see all items on the row? I mean, if the above written example would work, we would get just number of highest salary(7000), but what to do, if I want also the name of the person with the highest salary?
Thanks a lot for your help,