| 1 |
(* SShortWholeIO.def provides input/output of SHORTINT/SHORTCARD over channels. |
| 2 |
|
| 3 |
Copyright (C) 2013-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 SShortWholeIO; |
| 28 |
|
| 29 |
(* Input and output of whole numbers in decimal text form over |
| 30 |
default channels. The read result is of the type |
| 31 |
IOConsts.ReadResults. |
| 32 |
*) |
| 33 |
|
| 34 |
(* The text form of a signed whole number is |
| 35 |
["+" | "-"], decimal digit, {decimal digit} |
| 36 |
|
| 37 |
The text form of an unsigned whole number is |
| 38 |
decimal digit, {decimal digit} |
| 39 |
*) |
| 40 |
|
| 41 |
PROCEDURE ReadInt (VAR int: SHORTINT); |
| 42 |
(* Skips leading spaces, and removes any remaining characters |
| 43 |
from the default input channel that form part of a signed |
| 44 |
whole number. The value of this number is assigned |
| 45 |
to int. The read result is set to the value allRight, |
| 46 |
outOfRange, wrongFormat, endOfLine, or endOfInput. |
| 47 |
*) |
| 48 |
|
| 49 |
PROCEDURE WriteInt (int: SHORTINT; width: CARDINAL); |
| 50 |
(* Writes the value of int to the default output channel in |
| 51 |
text form, in a field of the given minimum width. |
| 52 |
*) |
| 53 |
|
| 54 |
PROCEDURE ReadCard (VAR card: SHORTCARD); |
| 55 |
(* Skips leading spaces, and removes any remaining characters |
| 56 |
from the default input channel that form part of an |
| 57 |
unsigned whole number. The value of this number is |
| 58 |
assigned to card. The read result is set to the value |
| 59 |
allRight, outOfRange, wrongFormat, endOfLine, or endOfInput. |
| 60 |
*) |
| 61 |
|
| 62 |
PROCEDURE WriteCard (card: SHORTCARD; width: CARDINAL); |
| 63 |
(* Writes the value of card to the default output channel in |
| 64 |
text form, in a field of the given minimum width. |
| 65 |
*) |
| 66 |
|
| 67 |
END SShortWholeIO. |