runtime error 2

Reply

Join Date: Jun 2009
Posts: 3
Reputation: mauimaui346 is an unknown quantity at this point 
Solved Threads: 0
mauimaui346 mauimaui346 is offline Offline
Newbie Poster

runtime error 2

 
0
  #1
Jun 24th, 2009
I am writing a program for a college assignment to compute grades of students. the code compiles ok, but i keep getting a runtime error 2. can anyone help?






Pascal and Delphi Syntax (Toggle Plain Text)
  1. {Author: George Brandon Miller}
  2. {Program: Grade Report - Compute the grade point average for students}
  3. Program Grades;
  4.  
  5. var
  6.  
  7.  
  8. { misc. program variables }
  9.  
  10. more_records:boolean; {end of file flag }
  11. line_count:integer; {lines written count}
  12. page_no:integer; {page count}
  13.  
  14.  
  15. {Student Variables}
  16. FileIn:typedfile; {Input File Handle}
  17. FileOut:text; {Output File Handle}
  18. SECTION_NUMBER:string[5]; {Section number of the class}
  19. STUDENT_ID:string[9]; {Student identification number}
  20. LAST_NAME:string[20]; {Students last name}
  21. FIRST_NAME:string[10]; {Students first name}
  22. RAW_SCORE:real; {Points totaled by the student}
  23. STUDENT_COUNT:integer; {total number of students}
  24. AVERAGE_SCORE:integer; {Average score for all the students}
  25. AVERAGE_GRADE:integer; {Grade for the student}
  26. PERCENT:real;
  27.  
  28. procedure read_record;
  29. begin
  30. if not Eof(fileIn) then
  31. readln(SECTION_NUMBER,STUDENT_ID,LAST_NAME,FIRST_NAME,RAW_SCORE)
  32. else
  33. more_records := False
  34. end; {read record}
  35.  
  36. procedure print_header; {print header at top of page}
  37.  
  38. begin
  39.  
  40. writeln(FileOut,space(14),'CIS150 GRADE REPORT',space(8),page_no);
  41. writeln(FileOut,space(17),'SECTION','SECTION_NUMBER');
  42. Writeln(FileOut);
  43. writeln(FileOut,space(9),'LAST',space(11),'FIRST',' RAW',' COMPUTED');
  44. writeln(FileOut,space(9),'NAME',space(11),'NAME',' SCORE',' GRADE');
  45. Writeln(FileOut);
  46. Writeln(FileOut);
  47. Writeln(FileOut);
  48. Writeln(FileOut);
  49. Writeln(FileOut,'STUDENT COUNT',STUDENT_COUNT);
  50. Writeln(FileOut,'AVERAGE SCORE',AVERAGE_SCORE);
  51. Writeln(FileOut,'AVERAGE GRADE',AVERAGE_GRADE);
  52.  
  53. end;
  54.  
  55. {INITIALIZE - open files and print header}
  56.  
  57. procedure initialize;
  58.  
  59. begin
  60.  
  61.  
  62. assign(fileIn,'C:\Users\Owner\Classes\CIS 150\Data\PRG3-150.DAT');
  63. reset(fileIn);
  64. assign(Fileout,'C:\Users\Owner\Classes\CIS 150\Data\grades.rpt');
  65. rewrite(fileout);
  66.  
  67. read_record;
  68.  
  69. print_header
  70.  
  71. end;
  72.  
  73. procedure process;
  74.  
  75. begin
  76.  
  77. {skip to new page if needed}
  78. Inc(line_count);
  79. if line_count > 50 then
  80. Print_header;
  81.  
  82. percent := (Raw_Score / 850.0) * 100.0;
  83. writeln(FileOut,Last_Name,Space(2),First_Name,Space(3),percent);
  84. read_record;
  85.  
  86. end;
  87.  
  88.  
  89. procedure wrapup;
  90.  
  91. begin
  92. writeln(FileOut);
  93. writeln(FileOut,'Student_Count');
  94. Close(FileIn);
  95. Close(FileOut);
  96. end;
  97.  
  98.  
  99. begin
  100. initialize;
  101.  
  102.  
  103. while more_records do
  104. process;
  105.  
  106.  
  107. wrapup
  108.  
  109. end.
Last edited by Ancient Dragon; Jun 25th, 2009 at 7:14 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 3
Reputation: mauimaui346 is an unknown quantity at this point 
Solved Threads: 0
mauimaui346 mauimaui346 is offline Offline
Newbie Poster

Re: runtime error 2

 
0
  #2
Jun 24th, 2009
I changed the filein:filetype; to fileIn:file; and now i get a runtime error 106...im completely lost...any help?
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 447
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: runtime error 2

 
0
  #3
Jun 25th, 2009
Is this a compiler error message?
Then 2:Identifier expected,106:Character expression expected
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 3
Reputation: mauimaui346 is an unknown quantity at this point 
Solved Threads: 0
mauimaui346 mauimaui346 is offline Offline
Newbie Poster

Re: runtime error 2

 
0
  #4
Jun 29th, 2009
Originally Posted by FlamingClaw View Post
Is this a compiler error message?
Then 2:Identifier expected,106:Character expression expected
Yes it is a compiler message. and i changed the file. but im still lost.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 447
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: runtime error 2

 
0
  #5
Jun 29th, 2009
ok,calm down a bit....now we know where the problem is,right..?...
run your program and look at the line where stops the program
and please paste that line,cause I can't run your program because of missing files...I hope that you understand what I'm talking about....

Error 2: Identifier expected.

I found this error when reading your code
procedure read_record;
begin
if not Eof(fileIn) then
readln(fileIn,SECTION_NUMBER,STUDENT_ID,LAST_NAME,FIRST_NAME,RAW_SCORE)
else
more_records := False
end;
Last edited by FlamingClaw; Jun 29th, 2009 at 6:30 pm.
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 447
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: runtime error 2

 
0
  #6
Jun 30th, 2009
By the way when I looking your code a bit closer I can't find any records ...why???
Create a new type 'something = record',got it?
I made a skeleton
  1. Program Solution;
  2.  
  3.  
  4. {new type for a student,it contains the data of a student}
  5. Type Stdnt = Record
  6. SECTION_NUMBER:string[5];
  7. STUDENT_ID:string[9];
  8. LAST_NAME:string[20];
  9. FIRST_NAME:string[10];
  10. RAW_SCORE:real;
  11. End;
  12. Var FileIn:File of Stdnt;{declares a file that contains only records}
  13. OneStudent:Stdnt; {one record}
  14.  
  15.  
  16. Procedure read_record;
  17. Begin
  18. If Not EoF(FileIn) Then Readln(FileIn,OneStudent)
  19. Else
  20. more_records := False
  21. End; {read record}
  22. {
  23. After calling this procedure,the OneStudent record is filled
  24. with data like : just example....
  25. OneStudent.SECTION_NUMBER := '12';
  26. OneStudent.STUDENT_ID :='3';
  27. OneStudent.LAST_NAME := 'Joe';
  28. OneStudent.FIRST_NAME := 'Smith';
  29. OneStudent.RAW_SCORE := 12.32;
  30. and you have to work with the OneStudent record
  31. }
  32.  
  33.  
  34. Begin {main}
  35.  
  36.  
  37. ReadLn;
  38. End.
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC