Subject Re: String question
From Edward Racht <eracht@yahoo.com>
Date Sun, 12 Nov 2023 10:05:19 -0500
Newsgroups dbase.getting-started

Greetings - Charlie,

Check out the dUFLP - StringEX.cc

    function Text2Num
       /*
          -------------------------------------------------------------
          Programmer..: Akshat Kapoor
          Date........: August, 2021
          Notes.......: Converts a character string with a numeric
                        value to the appropriate numeric value
                        in dBASE. Created to deal with input from
                        a CSV file, where many different issues
                        come up with numeric formats. The difficulty
                        is if the string has the "thousands" separator
                        (123,456.12), and it is a string, the val()
                        function stops at the separator, and returns
                        123, instead of the full numeric value. Other
                        issues such as negative numbers in parens,
                        different decimal point symbols for different
                        parts of the world, make things even more fun.
          Written for.: dBASE 2019
          Rev. History: August, 2021 -- KJM -- with Akshat's permission
                         co-opted it for the Import Data routines in the
                         dUFLP.
          Calls.......: None
          Usage.......: Text2Num( <cNumber>, <cDecimal> )
          Example.....: ? Text2Num( "123,456.12", "." )   --> 123456.12
                        ? Text2Num( "123.456,12", "," )   --> 123456.12
                        ? Text2Num( "(123.456,12)", "," ) --> -123456.12
          Returns.....: numeric value with no formatting except for
                        decimal
          Parameters..: cNumber = character string containing numeric value
                                  with whatever formatting is in the string
                        cDecimal = decimal point character. Default is "."

          NOTE: This is designed specifically for the purpose of converting
          numeric values that are stored in strings, to their actual
          numeric value. If you pass, say, a phone number string to this
          function, the results will be odd, to say the least.
          -------------------------------------------------------------

ed