>>Hi,
>>
>>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"
>>
>>
>>I tried TRANSFORM() but the second parameter has to match the number of decimal digits.
>>
>>Any suggestions?
>
>You need to signify the proposed size. In such cases, it's often desirable to use:
>
>CLEAR
>* 2.4
>? ALLTRIM(STR(2.4, 14, 1))
>
>* More generically
>* .00
>? JustDecimal(StrTrim(0.00, 2))
>
>* 500.32337
>? StrTrim(500.32337, 5)
>
>* 8.342
>? StrTrim(8.342, 3)
>
>
>
>FUNCTION StrTrim(tnVal, tnDecimals, tnWidth)
>RETURN ALLTRIM(STR(tnVal, IIF(TYPE("tnWidth") != "N", 14, tnWidth), IIF(TYPE("tnDecimals") != "N", SET("DECIMALS"), tnDecimals)))
>
>FUNCTION JustDecimal(tcValue)
>RETURN "." + GETWORDNUM(tcValue, 2, ".")
>
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.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham