InOutExample.Mod 974 B

12345678910111213141516171819202122232425262728293031323334353637
  1. MODULE InOutExample; (** AUTHOR "FOF"; PURPOSE "simple demo of simple in and out"; *)
  2. IMPORT In, Out, Commands, Streams;
  3. (* thread safe when executed in isolated commands context, e.g. in PET
  4. this does NOT imply that several commands in the same context would not produce unpredictable results.
  5. *)
  6. PROCEDURE Hello*;
  7. VAR name: ARRAY 32 OF CHAR;
  8. BEGIN
  9. IF In.String(name) THEN
  10. Out.String("Hello "); Out.String(name); Out.Ln;
  11. ELSE
  12. Out.String("Hello World!"); Out.Ln;
  13. END;
  14. END Hello;
  15. PROCEDURE Number*;
  16. VAR r: LONGREAL; name: ARRAY 32 OF CHAR;
  17. BEGIN
  18. IF In.String(name) & In.Real(r) THEN
  19. Out.String(name); Out.String(" = "); Out.Float(r); Out.Ln;
  20. Out.String(name); Out.String(" = "); Out.Float(r,20); Out.Ln;
  21. Out.String(name); Out.String(" = "); Out.Float(r,20,15,-1); Out.Ln;
  22. END;
  23. END Number;
  24. END InOutExample.
  25. SystemTools.Free InOutExample In Out ~
  26. InOutExample.Hello Oberon ~
  27. InOutExample.Hello ~
  28. InOutExample.Number pi 3.14159265358979323846E0;
  29. ~