[Oberon] In.Real not working

Duke Normandin dukeofpurl at gmx.com
Fri Apr 9 20:51:55 CEST 2021


@Dave Brown
@David Lightfoot

In.Open solved the problem!
My petty program works a treat!

[code]
(*  for voc compiler:  voc filename.ob2 -M
     for obnc compiler:
*)

MODULE tempConvert;
IMPORT In, Out;

(* global variables declared here *)
VAR choice:INTEGER;
VAR temp:REAL;

PROCEDURE fahr2cels(fahr:REAL):REAL;
BEGIN
   RETURN 0.5556*(fahr - 32)
END fahr2cels;

PROCEDURE cels2fahr( cels:REAL):REAL;
BEGIN
  RETURN cels * 1.8 + 32
END cels2fahr;

BEGIN (* main program body*)
choice := 0;
temp := 0.0;

Out.String("Temperature Conversion Utility");Out.Ln;
Out.String("------------------------------");Out.Ln;
Out.String("1 - Fahrenheit TO Celsius");Out.Ln;
Out.String("2 - Celsius TO Fahrenheit");Out.Ln;
Out.String("  - Enter your Choice");Out.Ln;
In.Int(choice);

CASE  choice OF
   1 : Out.String('Enter a number/temperature TO convert: ');
       In.Open;
       In.Real(temp);
       Out.Ln;Out.String("Your input was ");Out.Real(temp,3);Out.String(" Fahrenheit!");Out.Ln;
       Out.String("That's "); Out.Real( fahr2cels(temp),3);Out.String(" In Celsius!");

|  2 : Out.String("Enter a number/temperature TO convert: ");
       In.Open;
       In.Real(temp);
       Out.Ln;Out.String("Your input was ");Out.Real(temp,3);Out.String(" Celsius!");Out.Ln;
       Out.String("That's "); Out.Real(cels2fahr(temp),3);Out.String(" In Fahrenheit!");
 ELSE  Out.String("Sorry! Invalid Choice");
 END; (*CASE*)

Out.Ln;

END tempConvert.
[/code]

Now I need to go and read up on how to output the temperatures in non-scientific notation. I'll find it!!
Thx a bunch!!
--
Duke Normandin <dukeofpurl at gmx.com>


More information about the Oberon mailing list