GETNUMB - read a number from the current input unit.

Usage:

B:
   extrn getn.a, getn.l;
   val = getnumb( [c, n, sign, base, bn] );
C:
   #equate getn_a getn.a
   #equate getn_l getn.l
   extern int getn_a, getn_l;
   int getnumb( [int c, int n, int sign, int base, int bn] );

Where:

c
is the first character of the number. This argument is designed for situations where your program is scanning a line, comes upon a digit, and then wants to call GETNUMB to collect the rest of the number. Rather than backing up the input unit so that GETNUMB can get the number in full, you can pass GETNUMB the digit you've already obtained and let the function get the rest of the number. If "c" is zero or not specified, the first character of the number will be obtained from the input unit.
n
is the maximum number of digits allowed in the number being collected.
sign
is non-zero if the number is allowed to be signed. If "sign" is not given, it is assumed that the number could be signed.
base
is the base of the number to be input. If "base" has the value zero, GETNUMB assumes the number is decimal unless it is preceded by a zero, in which case it is taken to be octal. If "base" is non-zero, it should lie between 2 and 10 (inclusive). In this case, the number which is being collected is assumed to be of the given "base".
bn
is non-zero if preceding blanks cannot be skipped while scanning for the number. If "bn" is not specified, GETNUMB assumes that blanks can be skipped.
val
is a word containing the number which has been collected, in integer format.

Description:

GETNUMB reads a number from the current read unit and returns the number read. All arguments are optional.

GETNUMB makes use of two external variables. "getn.l" contains the last character obtained by GETNUMB. "getn.a" contains a status about the number which has just been collected. The possible values of this status are

-1
if a sign was found but no number
0
no number found (in which case "val" is zero)
1
a valid number was found

Examples:

getnumb()
    get the next number from the current read unit
getnumb(c)
    get the number starting with the character contained
    in "c"
getnumb(0, 10, 0, 10)
    get a decimal number of less than 10 digits

Copyright © 1996, Thinkage Ltd.