Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert number to a char string
Message
From
09/12/2019 03:07:58
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01672170
Message ID:
01672188
Views:
58
>>>I am trying to create a generic way to convert any number to a string. Here are some examples, of the number and how they should be as a string:
>>>
>>>
>>>2.4       ->  "2.4"
>>>.00       -> ".00"
>>>500.32337   -> "500.32337"
>>>8.342    -> "8.342"
>>>
>>>
>> [Rick Hodgin's reply]
>>
>Your StrTrim() is good; thank you. But it requires that I specify the number of decimals. And I am trying to figure how to do it for any number.
>That is, in my case, I have to SCAN records of a table where the column could have different values (as you see in my example above). And in each row, the numeric value has to be changed to the char; matching exactly.

Hi, Dmitry

I'm really intrigued about the ".00" example. Why wouldn't it be just "0"?

If it were,
EVL(ALLTRIM(STR(SomeNumericValue, 40, 18), 0, " ", "0", SET("Point")), "0")
would do the trick (sorry, I was too lazy to figure the value of the 2nd and 3rd STR() arguments exactly, so these are overly generous).
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform