I'm trying to emulate the stdlib c function strtol, as in:
long strtol(const char *s, char **endptr, int base)
To be used like this:
/* Get the checksum on the first digits */
for(i=0;i<len-2;i+=3) {
checkSum += (unsigned char)strtol(&code[i], NULL, 16);
}
Steve
On Thu, 2 Mar 2000 10:10:04 -0700, Palm Developer Forum wrote:
I think you mean StrAToL
This might work for you.
/**************************************************************************
* StrAToF JS *
**************************************************************************/
double StrAToF(char *string){
int i,j,k;
double deg,dec;
double value=0;
char buff1[30];
char buff2[30];
if(StrLen(string)==0)
return(NULL);
if(string[0] == '-')
k=1;
else
k=0;
/*string */
for(i=0;i<StrLen(string);i++)
if(string[i] != '.')
buff1[i]=string[i+k];
else{
j=i;
i=StrLen(string);
}
} /* end for */
buff1[j]='\0'; /* null terminate */
/* convert string decial to int */
for(i=j+1;i<StrLen(string);i++){
buff2[i-(j+1)]=string[i];
}
buff2[i-(j+1)]='\0';
for(i=StrLen(buff2);i<6;i++)
buff2[i]='0';
buff2[i+1]='\0';
deg=StrAToI(buff1);
dec=StrAToI(buff2);
if(dec > 9999999999)
dec=dec * .00000000001;
else if(dec > 999999999)
dec=dec * .0000000001;
else if(dec > 99999999)
dec=dec * .000000001;
else if(dec > 9999999)
dec=dec * .00000001;
else if(dec > 999999)
dec=dec * .0000001;
else if(dec > 99999)
dec=dec * .000001;
else if(dec > 9999)
dec=dec * .00001;
else if(dec > 999)
dec=dec * .0001;
else if(dec > 99)
dec=dec * .001;
else if(dec > 9)
dec=dec * .01;
else
dec=dec * .1;
value=deg+dec;
return(value);}//end function
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: Palm Developer Forum <[EMAIL PROTECTED]>
Sent: Thursday, March 02, 2000 8:52 AM
Subject: strtol function
> Greetings. Has anyone created an alternative to the standard C function
> strtol which isn't supported by the Palm OS? I trying to convert a
routine
> to manipulate hexidecimal character strings to run on the Palm but I
can't
> get there. Any help is greatly appreciated.
>
> Steve
>
>
>
>
>
> _______________________________________________________
> Get 100% FREE Internet Access powered by Excite
> Visit http://freeworld.excite.com
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
_______________________________________________________
Get 100% FREE Internet Access powered by Excite
Visit http://freeworld.excite.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html