Parent: [c017f0] (diff)

Child: [8d1c2d] (diff)

Download this file

NumConvert.def    204 lines (173 with data), 12.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
DEFINITION MODULE NumConvert;
(*------------------------------------------------------------------------*)
(* Modul fuer die Konvertierung Ganzahlen / Sting et. visa versa. *)
(* Modul for the conversion of whole numbers to string or visa versa. *)
(*------------------------------------------------------------------------*)
(* Implementation : Michael Riedl *)
(* Licence : GNU Lesser General Public License (LGPL) *)
(*------------------------------------------------------------------------*)
(* $Id: NumConvert.def,v 1.1 2015/09/13 20:48:41 mriedl Exp mriedl $ *)
FROM ConvTypes IMPORT ConvResults;
PROCEDURE IntToStrBased( I : LONGINT;
VAR Str : ARRAY OF CHAR;
base : CARDINAL;
VAR done : BOOLEAN);
(*----------------------------------------------------------------*)
(* Konvertiert die LONGINT-Zahl I zur entsprechenden Zeichenkette *)
(* mit der Darstellungsbasis base. Im Fehlerfalle wird done auf *)
(* falsch gesetzt. *)
(* *)
(* Converts the LONGINT I to the corresponding base "base" *)
(* string representation "Str". If the conversion failed done *)
(* will be set to false. *)
(*----------------------------------------------------------------*)
PROCEDURE CardToStrBased( C : LONGCARD;
VAR Str : ARRAY OF CHAR;
base : CARDINAL;
VAR done : BOOLEAN);
(*----------------------------------------------------------------*)
(* Konvertiert die LONGCARD-Zahl C zur entsprechenden Zeichen- *)
(* mit der Darstellungsbasis base. Im Fehlerfalle wird done auf *)
(* falsch gesetzt. *)
(* *)
(* Converts the LONGCARD C to the corresponding base "base" *)
(* string representation "Str". If the conversion failed done *)
(* will be set to false. *)
(*----------------------------------------------------------------*)
PROCEDURE StrToIntBased( Str : ARRAY OF CHAR;
base : CARDINAL;
VAR I : LONGINT;
VAR result : ConvResults);
(*----------------------------------------------------------------*)
(* Konvertiert die in Str enthaltene Zeichenkette in die *)
(* entsprechende LONGINT-Zahl I. Dabei wird f"ur Str die *)
(* Darstellungsbasis base angenommen. *)
(* *)
(* Converts the string "Str" in base "base" representation to an *)
(* equivalent LONGINT I. In case of an error result will be set *)
(* accordingly, if no error result = strAllRight will be returned *)
(*----------------------------------------------------------------*)
PROCEDURE StrToCardBased( Str : ARRAY OF CHAR;
base : CARDINAL;
VAR C : LONGCARD;
VAR result : ConvResults);
(*----------------------------------------------------------------*)
(* Konvertiert die in Str enthaltene Zeichenkette in die *)
(* entsprechende LONGCARD-Zahl C. Dabei wird f"ur Str die *)
(* Darstellungsbasis base angenommen. *)
(* *)
(* Converts the string "Str" in base "base" representation to an *)
(* equivalent LONGCARD C. In case of an error result will be set *)
(* accordingly, if no error result = strAllRight will be returned *)
(*----------------------------------------------------------------*)
PROCEDURE IntToString(i : INTEGER;
Breite : CARDINAL;
VAR Zahl : ARRAY OF CHAR;
VAR done : BOOLEAN);
(*----------------------------------------------------------------*)
(* Konvertiert die INTEGER-Zahl i zur entsprechenden Zeichenkette *)
(* mit der Darstellungsbasis 10. *)
(* *)
(* Converts the INTEGER i to the corresponding base 10 string *)
(* representation "Zahl" with width "Breite". If the conversion *)
(* failed done will be set to false *)
(*----------------------------------------------------------------*)
PROCEDURE StringToInt( Zahl : ARRAY OF CHAR;
VAR i : INTEGER;
VAR result : ConvResults);
(*----------------------------------------------------------------*)
(* Konvertiert die in Str enthaltene Zeichenkette in die *)
(* entsprechende INTEGER-Zahl i. Dabei wird f"ur Str die *)
(* Darstellungsbasis 10 angenommen. *)
(* *)
(* Converts the string "Zahl" in base 10 representation to an *)
(* equivalent integer i. In case of an error result will be set *)
(* accordingly, if no error result = strAllRight will be returned *)
(*----------------------------------------------------------------*)
PROCEDURE CardToString( c : CARDINAL;
Breite : CARDINAL;
VAR Zahl : ARRAY OF CHAR;
VAR done : BOOLEAN);
(*----------------------------------------------------------------*)
(* Konvertiert die CARDINAL-Zahl c zur entsprechenden Zeichen- *)
(* kette mit der Darstellungsbasis 10. *)
(* *)
(* Converts the CARDINAL c to the corresponding base 10 string *)
(* representation "Zahl" with width "Breite". If the conversion *)
(* failed done will be set to false *)
(*----------------------------------------------------------------*)
PROCEDURE StringToCard( Zahl : ARRAY OF CHAR;
VAR c : CARDINAL;
VAR result : ConvResults);
(*----------------------------------------------------------------*)
(* Konvertiert die in Str enthaltene Zeichenkette in die *)
(* entsprechende CARDINAL-Zahl c. Dabei wird f"ur Str die *)
(* Darstellungsbasis 10 angenommen. *)
(* *)
(* Converts the string "Zahl" in base 10 representation to an *)
(* equivalent CARDINAL c. In case of an error result will be set *)
(* accordingly, if no error result = strAllRight will be returned *)
(*----------------------------------------------------------------*)
PROCEDURE LongCardToString( C : LONGCARD;
Breite : CARDINAL;
VAR Zahl : ARRAY OF CHAR;
VAR done : BOOLEAN);
(*----------------------------------------------------------------*)
(* Konvertiert die LONGCARD-Zahl C zur entsprechenden Zeichenkette *)
(* mit der Darstellungsbasis 10. *)
(* *)
(* Converts the LONGCARD C to the corresponding base 10 string *)
(* representation "Zahl" with width "Breite". If the conversion *)
(* failed done will be set to false *)
(*----------------------------------------------------------------*)
PROCEDURE StringToLongCard(VAR ZahlStr : ARRAY OF CHAR;
VAR C : LONGCARD;
VAR result : ConvResults);
(*----------------------------------------------------------------*)
(* Konvertiert die in Str enthaltene Zeichenkette in die *)
(* entsprechende LONGCARD-Zahl C. Dabei wird f"ur Str die *)
(* Darstellungsbasis 10 angenommen. *)
(* *)
(* Converts the string "ZahlStr" in base 10 representation to an *)
(* equivalent LONGCARD C. In case of an error result will be set *)
(* accordingly, if no error result = strAllRight will be returned *)
(*----------------------------------------------------------------*)
PROCEDURE LongIntToString( I : LONGINT;
Breite : CARDINAL;
VAR Zahl : ARRAY OF CHAR;
VAR done : BOOLEAN);
(*----------------------------------------------------------------*)
(* Konvertiert die LONGINT-Zahl I zur entsprechenden Zeichenkette *)
(* mit der Darstellungsbasis 10 und Feldbreite "Breite". Im *)
(* Fehlerfalle wird done auf falsch gesetzt. *)
(* *)
(* Converts the LONGINT I to the corresponding base 10 string *)
(* representation "Zahl" with width "Breite". If the conversion *)
(* failed done will be set to false *)
(*----------------------------------------------------------------*)
PROCEDURE StringToLongInt(VAR ZahlStr : ARRAY OF CHAR;
VAR I : LONGINT;
VAR result : ConvResults);
(*----------------------------------------------------------------*)
(* Konvertiert die in ZahlStr enthaltene Zeichenkette in die *)
(* entsprechende LONGINT-Zahl I. Dabei wird f"ur Str die *)
(* Darstellungsbasis 10 angenommen. Im Fehlerfalle wird result *)
(* entsprechend gesetzt, ansonstern ist result = strAllRight *)
(* *)
(* Converts the string "ZahlStr" in base 10 representation to an *)
(* equivalent LONGINT I. In case of an error result will be set *)
(* accordingly, if no error result = strAllRight will be returned *)
(*----------------------------------------------------------------*)
PROCEDURE CardToBitStr( C : CARDINAL;
VAR BitStr : ARRAY OF CHAR;
nbits : CARDINAL);
(*----------------------------------------------------------------*)
(* Wandel den Wert von C in eine bitweise Repraesentation um *)
(* wobei mindestens nbits Bits ausgegeben werden. Das Nieder- *)
(* wertigste Byte wird zuerst ausgegeben. *)
(* *)
(* Convert the value provided in unsigned integer C to its *)
(* bitwise string representation using the first nbis Bits *)
(* of C. Lowest Bit on BitStr[0] *)
(*----------------------------------------------------------------*)
END NumConvert.