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.