Subject Re: String question
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Mon, 13 Nov 2023 10:02:42 -0800
Newsgroups dbase.getting-started

On 11/13/2023 9:57 AM, charlie wrote:
> Hi Heinz..
>
> I can't figure this one either.
>
> I want the result to be in character string but the val puts it in numeric.

Read the description in help for the definition of the function. Val()
converts the numeric value in a string to a number. Val() is short for
"value".

>
> Example
> c = "10000"
> ? transform(val(c), "@R 999,999")
> This does come up with 10,000 but in numeric.
> I tried this str(c) afterward but that doesn't work.
>
> Unless I am missing something.

The code above is not converting the value back to a string. It's just
outputting it.

c2 = transform(val(c), "@R 999,999")

Assigns the value to a new variable (so you aren't overwriting 'c'). If
you do this:

? c2

You should see that there is only a single leading space, if this were a
numeric value there would be more:

? 10000

This is a numeric value, you can tell among other things because of the
leading spaces in the output pane.

Hope that helps a bit.

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