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.)
Program JustInCase (input, output);
var
invalid_operator : boolean;
operator : char;
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;
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.I have tried writing any other program, some simple calculation, and it compiles fine, giving me error messages where necessary, but it doesn't rudely shut down. But every time I try to compile the above it rudely shuts down. Is there something in this code as written that is telling it to shut down??
Thanks for any advice,
Jonathan Gold
____________________________________________________________________ Get free email and a permanent address at http://www.netaddress.com/?N=1
