| 1 |
(* CardinalIO.def provides a PIM and Logitech compatible 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 CardinalIO ; |
| 28 |
|
| 29 |
EXPORT QUALIFIED Done, |
| 30 |
ReadCardinal, WriteCardinal, ReadHex, WriteHex, |
| 31 |
ReadLongCardinal, WriteLongCardinal, ReadLongHex, |
| 32 |
WriteLongHex, |
| 33 |
ReadShortCardinal, WriteShortCardinal, ReadShortHex, |
| 34 |
WriteShortHex ; |
| 35 |
|
| 36 |
|
| 37 |
VAR |
| 38 |
Done: BOOLEAN ; |
| 39 |
|
| 40 |
|
| 41 |
(* |
| 42 |
ReadCardinal - read an unsigned decimal number from the terminal. |
| 43 |
The read continues until a space, newline, esc or |
| 44 |
end of file is reached. |
| 45 |
*) |
| 46 |
|
| 47 |
PROCEDURE ReadCardinal (VAR c: CARDINAL) ; |
| 48 |
|
| 49 |
|
| 50 |
(* |
| 51 |
WriteCardinal - writes the value, c, to the terminal and ensures |
| 52 |
that at least, n, characters are written. The number |
| 53 |
will be padded out by preceeding spaces if necessary. |
| 54 |
*) |
| 55 |
|
| 56 |
PROCEDURE WriteCardinal (c: CARDINAL; n: CARDINAL) ; |
| 57 |
|
| 58 |
|
| 59 |
(* |
| 60 |
ReadHex - reads in an unsigned hexadecimal number from the terminal. |
| 61 |
The read continues until a space, newline, esc or |
| 62 |
end of file is reached. |
| 63 |
*) |
| 64 |
|
| 65 |
PROCEDURE ReadHex (VAR c: CARDINAL) ; |
| 66 |
|
| 67 |
|
| 68 |
(* |
| 69 |
WriteHex - writes out a CARDINAL, c, in hexadecimal format padding |
| 70 |
with, n, characters (leading with '0') |
| 71 |
*) |
| 72 |
|
| 73 |
PROCEDURE WriteHex (c: CARDINAL; n: CARDINAL) ; |
| 74 |
|
| 75 |
|
| 76 |
(* |
| 77 |
ReadLongCardinal - read an unsigned decimal number from the terminal. |
| 78 |
The read continues until a space, newline, esc or |
| 79 |
end of file is reached. |
| 80 |
*) |
| 81 |
|
| 82 |
PROCEDURE ReadLongCardinal (VAR c: LONGCARD) ; |
| 83 |
|
| 84 |
|
| 85 |
(* |
| 86 |
WriteLongCardinal - writes the value, c, to the terminal and ensures |
| 87 |
that at least, n, characters are written. The number |
| 88 |
will be padded out by preceeding spaces if necessary. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE WriteLongCardinal (c: LONGCARD; n: CARDINAL) ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
ReadLongHex - reads in an unsigned hexadecimal number from the terminal. |
| 96 |
The read continues until a space, newline, esc or |
| 97 |
end of file is reached. |
| 98 |
*) |
| 99 |
|
| 100 |
PROCEDURE ReadLongHex (VAR c: LONGCARD) ; |
| 101 |
|
| 102 |
|
| 103 |
(* |
| 104 |
WriteLongHex - writes out a LONGCARD, c, in hexadecimal format padding |
| 105 |
with, n, characters (leading with '0') |
| 106 |
*) |
| 107 |
|
| 108 |
PROCEDURE WriteLongHex (c: LONGCARD; n: CARDINAL) ; |
| 109 |
|
| 110 |
|
| 111 |
(* |
| 112 |
WriteShortCardinal - writes the value, c, to the terminal and ensures |
| 113 |
that at least, n, characters are written. The number |
| 114 |
will be padded out by preceeding spaces if necessary. |
| 115 |
*) |
| 116 |
|
| 117 |
PROCEDURE WriteShortCardinal (c: SHORTCARD; n: CARDINAL) ; |
| 118 |
|
| 119 |
|
| 120 |
(* |
| 121 |
ReadShortCardinal - read an unsigned decimal number from the terminal. |
| 122 |
The read continues until a space, newline, esc or |
| 123 |
end of file is reached. |
| 124 |
*) |
| 125 |
|
| 126 |
PROCEDURE ReadShortCardinal (VAR c: SHORTCARD) ; |
| 127 |
|
| 128 |
|
| 129 |
(* |
| 130 |
ReadShortHex - reads in an unsigned hexadecimal number from the terminal. |
| 131 |
The read continues until a space, newline, esc or |
| 132 |
end of file is reached. |
| 133 |
*) |
| 134 |
|
| 135 |
PROCEDURE ReadShortHex (VAR c: SHORTCARD) ; |
| 136 |
|
| 137 |
|
| 138 |
(* |
| 139 |
WriteShortHex - writes out a SHORTCARD, c, in hexadecimal format padding |
| 140 |
with, n, characters (leading with '0') |
| 141 |
*) |
| 142 |
|
| 143 |
PROCEDURE WriteShortHex (c: SHORTCARD; n: CARDINAL) ; |
| 144 |
|
| 145 |
|
| 146 |
END CardinalIO. |