Radical NetSurfer
2005-02-20 00:33:00 UTC
I am trying to obtain the Integer value of the
first series of Digits (left-most characters)
found in a string...
examples:
"1abc" We need to know the base for this to work right.
"123xyz"
"15,..." Basic and C have no problems with this one!
"100 54 7" Basic and C have no problems with this one!
In each case, I need a routine smart enough to
be able to return:
1 (as integer)
123 (as integer)
15 (as integet)
if Val(Str, intVar, errpos) is used, then
all I ever get is
intVar == 0
and
errpos = 1,2,3, etc...
INSTEAD of simply returning a VALID integer
value up to first invalid character found, just like
Qbasic, VBdos, and 'C' would do normally !!
Another factor here that I've noticed:
C offers the means to set the Base of the value
to be parsed from a string, I see no such function
offered in the TP/BP or FreePascal default supplied
library.... so how is that done?
where's sscanf() when you need it...
where's atoi() when you need it....
where's strtol() when you need it...
first series of Digits (left-most characters)
found in a string...
examples:
"1abc" We need to know the base for this to work right.
"123xyz"
"15,..." Basic and C have no problems with this one!
"100 54 7" Basic and C have no problems with this one!
In each case, I need a routine smart enough to
be able to return:
1 (as integer)
123 (as integer)
15 (as integet)
if Val(Str, intVar, errpos) is used, then
all I ever get is
intVar == 0
and
errpos = 1,2,3, etc...
INSTEAD of simply returning a VALID integer
value up to first invalid character found, just like
Qbasic, VBdos, and 'C' would do normally !!
Another factor here that I've noticed:
C offers the means to set the Base of the value
to be parsed from a string, I see no such function
offered in the TP/BP or FreePascal default supplied
library.... so how is that done?
where's sscanf() when you need it...
where's atoi() when you need it....
where's strtol() when you need it...