>I've already posted a message for a problem with FlpAToF. I'm not
>found a good solution yet. I try to write my own conversion method,
>and I've tried using the StrAToI function :

/************************************
  * GetFloatFromString
  * extract a floating point number from a string.
  * NOTE: the only punctuation in the string is the decimal separator that
  * separates the left-hand and right-hand parts of the numbers. This is because
  * users cannot enter thousands-delimiting characters in numbers fields.
  ************************************/

float   GetFloatFromString ( Char * str ) {

        Char            part1 [12], part2 [12];
        float           fval1, fval2, fresult;
        Int16           j, k;

        fval1 = 0.0;    part1 [0] = '\0';
        fval2 = 0.0;    part2 [0] = '\0';

// strip off LHS of number

        j = 0;
        while (( str [ j ] != '\0' ) &&
                         ( str [ j ] != Dsep )) {
                part1 [ j ] = str [ j ];        // get LHS
                j++;
        }

        part1 [ j ] = '\0';     // done, terminate it

// strip off RHS of number

        k = 0;
        if (  str [ j ] == Dsep ) j++;
        while ( str [ j ] != '\0' ) {
                part2 [ k ] = str [ j ]; // get RHS
                j++;    k++;
        }

        part2 [ k ] = '\0';     // done, terminate it

// convert the two parts to floating point #s

        fval1 = ( float ) StrAToI ( part1 );
        fval2 = ( float ) StrAToI ( part2 );

// convert RHS to proper fraction

        for ( j = 1; j <= StrLen ( part2 ); j++ ) {
                fval2 = fval2 / 10.0;
                fval2 = fval2;
        }

// combine the results

        fresult = fval1 + fval2;
        return ( fresult );

}
-------------------------------------------
Creative Digital Publishing Inc.
1315 Palm Street, San Luis Obispo, CA 93401-3117
-------------------------------------------
805.784.9461              805.784.9462 (fax)
[EMAIL PROTECTED]       http://www.cdpubs.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to