"John J. Corelli" <[EMAIL PROTECTED]> writes:
> I'm guessing you have looked extensively through the reference for a single
> function to do this and have simply overlooked the low level functions that
> you can use in order to write your own function in 'C' to do this. ;)
>
> You're going to have to loop through the string to the terminating '\0' at
> the end
> all the while doing a test on each character to see if it's a number or not.
>
> Something like this (or some variant) should work:
>
> Boolean StringIsAllNumbers(char *strptr)
> {
> char ch;
> int i;
> Boolean StringIsAllNumbers = true;
>
> for(i=0; i<strlen(strptr); i++)
> {
> ch = *(strptr++);
> if (!TxtCharIsDigit(ch))
> StringIsAllNumbers = false;
> }
Note that this is assuming that 1 character == 1 byte, which is not
necessarily true. A palm with the international manager supports
multi-byte characters in strings. Better would be (off the top of my
head):
UInt16 i = 0;
Boolean StringIsAllNumbers = true;
while (StringIsAllNumbers && i < StrLen(strptr)) {
WChar ch;
i += TxtGetNextChar(strptr, i, &ch);
if (!TxtCharIsDigit(ch)) StringIsAllNumbers = false;
}
--
Dave Carrigan ([EMAIL PROTECTED]) | Yow! I'm thinking about DIGITAL
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | READ-OUT systems and
Seattle, WA, USA | computer-generated IMAGE
http://www.rudedog.org/ | FORMATIONS..
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/