Modula-2 || Compiler & Tools || Library || Search Engine


Ulm's Modula-2 Library:
StrToNum


NAME

StrToNum - string to number conversions

SYNOPSIS

PROCEDURE StrToCard(str: ARRAY OF CHAR;
		    VAR card: CARDINAL): BOOLEAN;
PROCEDURE StrToInt(str: ARRAY OF CHAR;
		   VAR integ: INTEGER): BOOLEAN;
PROCEDURE StrToOct(str: ARRAY OF CHAR;
		   VAR card: CARDINAL): BOOLEAN;
PROCEDURE StrToHex(str: ARRAY OF CHAR;
		   VAR card: CARDINAL): BOOLEAN;

DESCRIPTION

StrToCard converts str to the CARDINAL card. Leading or trailing blanks, tabs, and newlines are ignored. If str does not fit the syntax, [+] digit {digit}, or if the resulting number exceeds CARDINAL range, the function value will be FALSE, otherwise TRUE.

StrToInt converts str to the INTEGER integ in analogous manner, where str must fit the syntax:

[+|-] digit {digit} .

StrToOct and StrToHex work like StrToCard but read str as a number in either octal or hexadecimal representation, respectively.

SEE ALSO

Conversions

AUTHOR

Martin Hasch, University of Ulm
Edited by: borchert, last change: 1997/02/25, revision: 1.5, converted to HTML: 1997/04/28

Modula-2 || Compiler & Tools || Library || Search Engine