| | |
runtime error 2
![]() |
•
•
Join Date: Jun 2009
Posts: 3
Reputation:
Solved Threads: 0
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)
{Author: George Brandon Miller} {Program: Grade Report - Compute the grade point average for students} Program Grades; var { misc. program variables } more_records:boolean; {end of file flag } line_count:integer; {lines written count} page_no:integer; {page count} {Student Variables} FileIn:typedfile; {Input File Handle} FileOut:text; {Output File Handle} SECTION_NUMBER:string[5]; {Section number of the class} STUDENT_ID:string[9]; {Student identification number} LAST_NAME:string[20]; {Students last name} FIRST_NAME:string[10]; {Students first name} RAW_SCORE:real; {Points totaled by the student} STUDENT_COUNT:integer; {total number of students} AVERAGE_SCORE:integer; {Average score for all the students} AVERAGE_GRADE:integer; {Grade for the student} PERCENT:real; procedure read_record; begin if not Eof(fileIn) then readln(SECTION_NUMBER,STUDENT_ID,LAST_NAME,FIRST_NAME,RAW_SCORE) else more_records := False end; {read record} procedure print_header; {print header at top of page} begin writeln(FileOut,space(14),'CIS150 GRADE REPORT',space(8),page_no); writeln(FileOut,space(17),'SECTION','SECTION_NUMBER'); Writeln(FileOut); writeln(FileOut,space(9),'LAST',space(11),'FIRST',' RAW',' COMPUTED'); writeln(FileOut,space(9),'NAME',space(11),'NAME',' SCORE',' GRADE'); Writeln(FileOut); Writeln(FileOut); Writeln(FileOut); Writeln(FileOut); Writeln(FileOut,'STUDENT COUNT',STUDENT_COUNT); Writeln(FileOut,'AVERAGE SCORE',AVERAGE_SCORE); Writeln(FileOut,'AVERAGE GRADE',AVERAGE_GRADE); end; {INITIALIZE - open files and print header} procedure initialize; begin assign(fileIn,'C:\Users\Owner\Classes\CIS 150\Data\PRG3-150.DAT'); reset(fileIn); assign(Fileout,'C:\Users\Owner\Classes\CIS 150\Data\grades.rpt'); rewrite(fileout); read_record; print_header end; procedure process; begin {skip to new page if needed} Inc(line_count); if line_count > 50 then Print_header; percent := (Raw_Score / 850.0) * 100.0; writeln(FileOut,Last_Name,Space(2),First_Name,Space(3),percent); read_record; end; procedure wrapup; begin writeln(FileOut); writeln(FileOut,'Student_Count'); Close(FileIn); Close(FileOut); end; begin initialize; while more_records do process; wrapup end.
Last edited by Ancient Dragon; Jun 25th, 2009 at 7:14 am. Reason: add code tags
Is this a compiler error message?
Then 2:Identifier expected,106:Character expression expected
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...
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...
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;
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...
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...
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
Create a new type 'something = record',got it?
I made a skeleton
pascal Syntax (Toggle Plain Text)
Program Solution; {new type for a student,it contains the data of a student} Type Stdnt = Record SECTION_NUMBER:string[5]; STUDENT_ID:string[9]; LAST_NAME:string[20]; FIRST_NAME:string[10]; RAW_SCORE:real; End; Var FileIn:File of Stdnt;{declares a file that contains only records} OneStudent:Stdnt; {one record} Procedure read_record; Begin If Not EoF(FileIn) Then Readln(FileIn,OneStudent) Else more_records := False End; {read record} { After calling this procedure,the OneStudent record is filled with data like : just example.... OneStudent.SECTION_NUMBER := '12'; OneStudent.STUDENT_ID :='3'; OneStudent.LAST_NAME := 'Joe'; OneStudent.FIRST_NAME := 'Smith'; OneStudent.RAW_SCORE := 12.32; and you have to work with the OneStudent record } Begin {main} ReadLn; 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...
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...
![]() |
Similar Threads
- Runtime Error -21470024770 (8007007e) (Windows NT / 2000 / XP)
- Runtime Error 226 (Windows 95 / 98 / Me)
- runtime error#58 (Visual Basic 4 / 5 / 6)
- "The Sims" visual C++ runtime error, what shall i do? (Windows Software)
- Visual Runtime Error, Sound Problem, Disabled Norton and more! (Windows NT / 2000 / XP)
- Runtime Error 424 object required (was: Please Help!) (Visual Basic 4 / 5 / 6)
- Runtime error using Incredimail on XP (Windows NT / 2000 / XP)
- Runtime error ??!! (Windows 95 / 98 / Me)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: function lowcase(s: string): string;
- Next Thread: using C# dlls in delphi
| Thread Tools | Search this Thread |





