[Seed7-users] Seed7: RANGE_ERROR
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
|
From: Duke N. <sid...@gm...> - 2021-11-13 14:23:49
|
This is my first ever Seed7 program! I can't seem to find the bug
in the code. Line 30 I think is the problem, but why?
*** Uncaught exception RANGE_ERROR raised with
{raise RANGE_ERROR }
Stack:
in raise (ref EXCEPTION: anException)
at /home/dnormandin/git/seed7/s(323) in (attr ) (ref : ) at (463)
in (inout : , inout : ) at (102)
in (inout : ) at (170)
in at (31)
Process s7 exited with code 0
[code]
$ include "seed7_05.s7i";
$ include "complex.s7i";
$ include "char.s7i";
$ include "console.s7i";
const func float: fahr2cels (in float: temp) is
return 0.5556 * (temp - 32.0);
const func float: cels2fahr (in float: temp) is
return (temp * 1.8) + 32.0;
const proc: main is func
local
var float: temp is 0.0;
var char: choice is ' ';
var text: console is STD_NULL;
begin
console := open(CONSOLE);
clear(console);
while choice <> 'q' do
writeln("\nTemperature Conversion Utility");
writeln("------------------------------");
writeln("a - Fahrenheit TO Celsius");
writeln("b - Celsius TO Fahrenheit");
writeln("q - To exit the program");
write("Enter your choice ");
readln(choice);
case choice of
when {'a'}:
write("Enter a number to convert ");
readln(temp);
writeln("\nYour input was " <& temp <& " degrees
Fahrenheit!");
write("That's " <& fahr2cels(temp) <& " degrees
Celsius!");
write("\nPress any key to continue ..");
readln;
clear(console);
when {'b'}:
write("Enter a number to convert ");
readln(temp);
writeln("Your input was " <& temp <& " degrees
Fahrenheit!");
write("That's " <& cels2fahr(temp) <& " degrees
Celsius!");
writeln("\nPress any key to continue ..");
readln;
clear(console);
when {'q'}:
writeln("Good bye!");
writeln("\nPress any key to continue ..");
readln;
otherwise:
writeln("Sorry! Invalid choice!");
writeln("\nPress any key to continue ..");
readln;
clear(console);
end case;
end while;
end func;
[/code]
--
Duke Normandin <sid...@gm...>
|