[fpc-pascal]FreePascal rudely shuts down when I try to compile this particular code
Peter Vreman
peter at freepascal.org
Mon May 7 10:24:32 CEST 2001
> I am having an odd problem. The following code may have bugs, but I cannot
> tell, as this is what keeps happening: whenever I try to compile this code (
> Alt + F9 ) something flashes very fast on the screen and then FreePascal
> abruptly closes down! (Incidentally this code is from a tutorial I am reading,
> though I've changed its name.)
It's a bug in the compiler that it crashes. Please try a snapshot, that should not crash.
>
> Program JustInCase (input, output);
> var
> invalid_operator : boolean;
> operator : char;
operator is a reserved keyword in FPC. You should replace it by some other name like
'oper'
> num1, num2, result : real;
> begin
> invalid_operator := FALSE;
> writeln('Enter two numbers and an operator in the format');
> writeln(' number1 operator number2');
> readln( num1 ); readln( operator ); readln( num2 );
> case operator of
> '*' : result := num1 * num2;
> '/' : result := num1 / num2;
> '+' : result := num1 + num2;
> '-' : result := num1 - num2;
> otherwise invalid_operator := TRUE;
Here a line with 'end;' is missing to terminated the case statement.
> if invalid_operator then
> writeln('Invalid operator')
> else
> writeln(num1:4:2, ' ',operator,' ', num2:4:2, ' is
> ',result:5:2) {this line isn't wrapped on my screen}
>
> end.
More information about the fpc-pascal
mailing list