| 1 |
(* RealInOut.def provides a compatible RealInOut PIM 234 module. |
| 2 |
|
| 3 |
Copyright (C) 2004-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE RealInOut ; |
| 28 |
|
| 29 |
EXPORT QUALIFIED SetNoOfDecimalPlaces, |
| 30 |
ReadReal, WriteReal, WriteRealOct, |
| 31 |
ReadLongReal, WriteLongReal, WriteLongRealOct, |
| 32 |
ReadShortReal, WriteShortReal, WriteShortRealOct, |
| 33 |
Done ; |
| 34 |
|
| 35 |
CONST |
| 36 |
DefaultDecimalPlaces = 6 ; |
| 37 |
|
| 38 |
VAR |
| 39 |
Done: BOOLEAN ; |
| 40 |
|
| 41 |
|
| 42 |
(* |
| 43 |
SetNoOfDecimalPlaces - number of decimal places WriteReal and |
| 44 |
WriteLongReal should emit. This procedure |
| 45 |
can be used to override the default |
| 46 |
DefaultDecimalPlaces constant. |
| 47 |
*) |
| 48 |
|
| 49 |
PROCEDURE SetNoOfDecimalPlaces (places: CARDINAL) ; |
| 50 |
|
| 51 |
|
| 52 |
(* |
| 53 |
ReadReal - reads a real number, legal syntaxes include: |
| 54 |
100, 100.0, 100e0, 100E0, 100E-1, E2, +1E+2, 1e+2 |
| 55 |
*) |
| 56 |
|
| 57 |
PROCEDURE ReadReal (VAR x: REAL) ; |
| 58 |
|
| 59 |
|
| 60 |
(* |
| 61 |
WriteReal - writes a real to the terminal. The real number |
| 62 |
is right justified and, n, is the minimum field |
| 63 |
width. |
| 64 |
*) |
| 65 |
|
| 66 |
PROCEDURE WriteReal (x: REAL; n: CARDINAL) ; |
| 67 |
|
| 68 |
|
| 69 |
(* |
| 70 |
WriteRealOct - writes the real to terminal in octal words. |
| 71 |
*) |
| 72 |
|
| 73 |
PROCEDURE WriteRealOct (x: REAL) ; |
| 74 |
|
| 75 |
|
| 76 |
(* |
| 77 |
ReadLongReal - reads a LONGREAL number, legal syntaxes include: |
| 78 |
100, 100.0, 100e0, 100E0, 100E-1, E2, +1E+2, 1e+2 |
| 79 |
*) |
| 80 |
|
| 81 |
PROCEDURE ReadLongReal (VAR x: LONGREAL) ; |
| 82 |
|
| 83 |
|
| 84 |
(* |
| 85 |
WriteLongReal - writes a LONGREAL to the terminal. The real number |
| 86 |
is right justified and, n, is the minimum field |
| 87 |
width. |
| 88 |
*) |
| 89 |
|
| 90 |
PROCEDURE WriteLongReal (x: LONGREAL; n: CARDINAL) ; |
| 91 |
|
| 92 |
|
| 93 |
(* |
| 94 |
WriteLongRealOct - writes the LONGREAL to terminal in octal words. |
| 95 |
*) |
| 96 |
|
| 97 |
PROCEDURE WriteLongRealOct (x: LONGREAL) ; |
| 98 |
|
| 99 |
|
| 100 |
(* |
| 101 |
ReadShortReal - reads a SHORTREAL number, legal syntaxes include: |
| 102 |
100, 100.0, 100e0, 100E0, 100E-1, E2, +1E+2, 1e+2 |
| 103 |
*) |
| 104 |
|
| 105 |
PROCEDURE ReadShortReal (VAR x: SHORTREAL) ; |
| 106 |
|
| 107 |
|
| 108 |
(* |
| 109 |
WriteShortReal - writes a SHORTREAL to the terminal. The real number |
| 110 |
is right justified and, n, is the minimum field |
| 111 |
width. |
| 112 |
*) |
| 113 |
|
| 114 |
PROCEDURE WriteShortReal (x: SHORTREAL; n: CARDINAL) ; |
| 115 |
|
| 116 |
|
| 117 |
(* |
| 118 |
WriteShortRealOct - writes the SHORTREAL to terminal in octal words. |
| 119 |
*) |
| 120 |
|
| 121 |
PROCEDURE WriteShortRealOct (x: SHORTREAL) ; |
| 122 |
|
| 123 |
|
| 124 |
END RealInOut. |