| 1 |
(* Library module defined by the International Standard |
| 2 |
Information technology - programming languages |
| 3 |
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language. |
| 4 |
|
| 5 |
Copyright ISO/IEC (International Organization for Standardization |
| 6 |
and International Electrotechnical Commission) 1996-2021. |
| 7 |
|
| 8 |
It may be freely copied for the purpose of implementation (see page |
| 9 |
707 of the Information technology - Programming languages Part 1: |
| 10 |
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *) |
| 11 |
|
| 12 |
DEFINITION MODULE WholeStr; |
| 13 |
|
| 14 |
(* Whole-number/string conversions *) |
| 15 |
|
| 16 |
IMPORT |
| 17 |
ConvTypes; |
| 18 |
|
| 19 |
TYPE |
| 20 |
ConvResults = ConvTypes.ConvResults; |
| 21 |
(* strAllRight, strOutOfRange, strWrongFormat, strEmpty *) |
| 22 |
|
| 23 |
(* the string form of a signed whole number is |
| 24 |
["+" | "-"], decimal digit, {decimal digit} |
| 25 |
*) |
| 26 |
|
| 27 |
PROCEDURE StrToInt (str: ARRAY OF CHAR; VAR int: INTEGER; |
| 28 |
VAR res: ConvResults); |
| 29 |
(* Ignores any leading spaces in str. If the subsequent |
| 30 |
characters in str are in the format of a signed whole |
| 31 |
number, assigns a corresponding value to int. Assigns |
| 32 |
a value indicating the format of str to res. |
| 33 |
*) |
| 34 |
|
| 35 |
PROCEDURE IntToStr (int: INTEGER; VAR str: ARRAY OF CHAR); |
| 36 |
(* Converts the value of int to string form and copies the |
| 37 |
possibly truncated result to str. *) |
| 38 |
|
| 39 |
(* the string form of an unsigned whole number is |
| 40 |
decimal digit, {decimal digit} |
| 41 |
*) |
| 42 |
|
| 43 |
PROCEDURE StrToCard (str: ARRAY OF CHAR; |
| 44 |
VAR card: CARDINAL; |
| 45 |
VAR res: ConvResults); |
| 46 |
(* Ignores any leading spaces in str. If the subsequent |
| 47 |
characters in str are in the format of an unsigned |
| 48 |
whole number, assigns a corresponding value to card. |
| 49 |
Assigns a value indicating the format of str to res. |
| 50 |
*) |
| 51 |
|
| 52 |
PROCEDURE CardToStr (card: CARDINAL; VAR str: ARRAY OF CHAR); |
| 53 |
(* Converts the value of card to string form and copies the |
| 54 |
possibly truncated result to str. *) |
| 55 |
|
| 56 |
END WholeStr. |