riannaloop
riannaloop

Reputation: 11

Whats wrong with this pascal syntax??--causing compiler error

I'm seriously tired and I can't find the error with this code. The meat of the matter lies in the fact that my compiler keeps returning the error:

Fatal: Syntax error, ; expected, but identifier ID found

Thats the only error, and its causing it not to run. My code is pretty simple. It keeps expecting a semi-colon where I'mt trying to read an array ID. I thought it was because i declared my array incorrectly, so I checked and I'm p sure it's fine?

Then i thought 'n' wasn't counting, so i switched from a repeat until to a for loop. Same issue. Can anyone see what the problem is, because I definitely can't :(

CODE BELOW:

program enteridentification;
uses
    crt;
var
   name:array[1..40] of string;
    ID:array[1..40] of string;
    grade_level:array[1..40] of string;
    initial_fee:array[1..40] of real;
    final_fee:array[1..40] of real;
n, count:integer;
begin
    n:=1;
    count:=1;
    FOR n:= 1 to 2 DO
        begin
         writeln ('Record No:',count);
         writeln ('Enter your ID number. Remember it is in the format XX19PPP.');
         writeln(' XX - first and last name initial. 19 - graduation year (constant). XXX - order in register (001, 002, 003 etc.)');
         readln ID[n];
         end;
end.

Upvotes: 0

Views: 157

Answers (1)

No'am Newman
No'am Newman

Reputation: 6477

The 'readln' line should have brackets around ID[n] - this is the parameter that you are passing to the readln procedure.

readln (ID[n]);

Whenever you are too tired to program: go to sleep and look at the program another day.

Upvotes: 1

Related Questions