| 1 |
(* LongIO.mod provides a Logitech-3.0 compatible library for GNU Modula-2. |
| 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 |
IMPLEMENTATION MODULE LongIO ; |
| 28 |
|
| 29 |
FROM DynamicStrings IMPORT String, InitString, KillString, RemoveWhitePrefix ; |
| 30 |
FROM StringConvert IMPORT StringToLongInteger, LongIntegerToString ; |
| 31 |
|
| 32 |
IMPORT InOut ; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
PROCEDURE ReadLongInt (VAR i: LONGINT) ; |
| 37 |
VAR |
| 38 |
s: String ; |
| 39 |
BEGIN |
| 40 |
s := RemoveWhitePrefix(InOut.ReadS()) ; |
| 41 |
IF InOut.Done |
| 42 |
THEN |
| 43 |
i := StringToLongInteger(s, 10, Done) |
| 44 |
ELSE |
| 45 |
Done := FALSE |
| 46 |
END ; |
| 47 |
s := KillString(s) |
| 48 |
END ReadLongInt ; |
| 49 |
|
| 50 |
|
| 51 |
PROCEDURE WriteLongInt (i: LONGINT; n: CARDINAL) ; |
| 52 |
VAR |
| 53 |
s: String ; |
| 54 |
BEGIN |
| 55 |
IF i<0 |
| 56 |
THEN |
| 57 |
s := KillString(InOut.WriteS(LongIntegerToString(i, n, ' ', TRUE, 10, FALSE))) |
| 58 |
ELSE |
| 59 |
s := KillString(InOut.WriteS(LongIntegerToString(i, n, ' ', FALSE, 10, FALSE))) |
| 60 |
END ; |
| 61 |
Done := TRUE |
| 62 |
END WriteLongInt ; |
| 63 |
|
| 64 |
|
| 65 |
END LongIO. |