Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 85 Expected ";"

Status
Not open for further replies.

Dubbemiah

Programmer
Apr 2, 2005
6
US
Code:
program myst;
uses crt;
var name: string;
pref: byte;
yn1: char;
(*procedure name_prefix; forward;*)
procedure enter_name;

begin
     clrscr;
          TextColor(3);
          writeln ('Welcome to Mystrunner.  Before we get any further, ');
          writeln ('please enter the name you wish to be called:');
          TextColor(4);
          read (name)
end;


procedure enter_name_yn;
begin
     writeln ('');
     writeln ('So you wish to be called (name)? Y:N ');
     yn1:=readkey;
     case yn1 of
          #89 : writeln ('(name) it is!');
          #121 : writeln ('(name) it is!');
          #78 : enter_name;
          #110 : enter_name;
          else enter_name_yn;
end;

begin
clrscr;
[COLOR=red]end.[/color]

I'm getting an expected ";" at my "end." in my main block code. This is supposed to be my main block? Why am I getting this error at runtime?
 
You seem to be missing an end at the end of the case statement.

Code:
procedure enter_name_yn;
begin
     writeln ('');
     writeln ('So you wish to be called (name)? Y:N ');
     yn1:=readkey;
     case yn1 of
          #89 : writeln ('(name) it is!');
          #121 : writeln ('(name) it is!');
          #78 : enter_name;
          #110 : enter_name;
          else enter_name_yn;
     [b]end[/b]
end;

begin
clrscr;
end.

As far as the compiler is concerned you are missing a 'terminator' and so it is just suggesting a ';'
 
stackdump - I would disagree.

That actually depends on the compiler you are using.

Standard Pascal will not allow a semicolon before an End, Borland Compilers don't complain either way. I think that the reason that some compilers allow it before End is to simplify things for the programmer.
 

Agreed, some compilers accept this, others dont.

But my reasoning is that since the error occurs at run time (rather than compile time), my first guess would be that the error may be a consequence of the "read" syntax.



 
I take your point, but would a semicolon error be reported at run time?

Surely, the compiler would pick this up?

Obviously we don't know which compiler is being used, but if it has a RUN option, which compiles and then runs, then it may appear that the error is a run time error.

It obvioiulsy wouldn't hurt to add the semicolon, in which case one should also be added after the end that I added.

I think we will have to wait for dubbemiah to come back and confirm exactly what the problem is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top