| Subject |
Re: convert a number like 1174.88 to a character field |
| From |
Ken Mayer <dbase@nospam.goldenstag.net> |
| Date |
Sat, 6 Dec 2025 13:48:23 -0800 |
| Newsgroups |
dbase.getting-started |
On 12/6/2025 1:30 PM, Tom wrote:
> On 12/6/25 8:13 AM, Ken Mayer wrote:
>> On 12/5/2025 10:24 PM, Lee Grant wrote:
>>> Ken,
>>>
>>> That would be the function property of @R "@R 9,999.99" which will
>>> format the number with place holders that will appear in printout but
>>> not in the field (comma, and period (or decimal separator)) to allow
>>> the number to only appear like this, without rounding any said
>>> number, unless someone coded the conversion of a variable and then
>>> fed it to this, then the number would already be rounded up or down
>>> per that coding, not this format via Picture and Function formatting.
>>
>> Yes, I was very tired at the time I tried this. And the picture
>> doesn't work here. I did try it again using the @R or @ symbols. The
>> string at the end inserts the first character as a leading character
>> if needed, and multiples if needed. So in my example:
>>
>> ? str( 1174.88, 8 , 2, "@R9,999.99" )
>>
>> Produces:
>>
>> @1174.88
>>
>> It ignores everything else. That could be a * or anything, but it
>> should be a simple symbol. I know there is a function in dBASE that
>> takes the picture to convert a numeric value to a string, but I can
>> never remember it.
>>
>> Ken
>>
> Hi all,
>
> Found this in my files under:
>
> Programming Newsgroup
>
> "Thousand seperator on a variable"
>
> 10/28/2019
>
> by KJM
>
> On 10/28/2019 12:51 PM, Peter Balfour wrote:
> > On 28/10/2019 11:16, Joshua Oyeladun wrote:
> >> How can i convert a numeric variable to a string with the number
> >> having thousand seperator. I need jelp please
> >>
> >
> > This any good?
> > works up to a few million.
> >
>
> Might be simpler:
>
>
> nVar = 10000000
> ? transform( nVar, "999,999,999" )
>
> and if you need the value with decimals:
>
> nVar = 10000000
> ? transform( nVar, "999,999,999.99" )
>
That's the function I can never remember! Thanks ... it's exactly what I
would have suggested if I could have remembered it. ;)
Ken
--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
dBASE DOS to Windows Tutorial:
http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm
|
|