1. numbers to text

I have a sequence of many floating point numbers.
I would like to check the length of each of them using getTextExtent() but text
data is required by this function and I am getting a
type check error when I use sequence[n].
If I include the variable assigned to sequence[n] in quotation marks it will
print the name of the variable.. How do I change the
value of the variable into text notation. ie what's the Euphoria equivalent of
the basic STR$() function.
I've read the sequence doc. and the examples for string literals are there but I
can't find anything for string variables.Thanks in
advance.
Regards
Bob

new topic     » topic index » view message » categorize

2. Re: numbers to text

Hello Bob,

>I have a sequence of many floating point numbers.
>I would like to check the length of each of them using getTextExtent() but
>text data is required by this function and I am getting a
>type check error when I use sequence[n].
>If I include the variable assigned to sequence[n] in quotation marks it
>will print the name of the variable.. How do I change the
>value of the variable into text notation. ie what's the Euphoria equivalent
>of the basic STR$() function.
>I've read the sequence doc. and the examples for string literals are there
>but I can't find anything for string variables.Thanks in
>advance.
>Regards
>Bob

I think what you want is the sprint() function in misc.e
example:

include misc.e
atom num
sequence text
num = 15.1976
text = sprint (num) -- text is now "15.1976"
? length (text) -- will print 7

later,
Lewis Townsend
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

new topic     » goto parent     » topic index » view message » categorize

3. Re: numbers to text

On Wed, 30 Aug 2000, you wrote:
> I have a sequence of many floating point numbers.
> I would like to check the length of each of them using getTextExtent() but
> text data is required by this function and I am getting a
> type check error when I use sequence[n].
> If I include the variable assigned to sequence[n] in quotation marks it will
> print the name of the variable.. How do I change the
> value of the variable into text notation. ie what's the Euphoria equivalent of
> the basic STR$() function.
> I've read the sequence doc. and the examples for string literals are there but
> I can't find anything for string variables.Thanks in
> advance.
> Regards
> Bob

-- see sprintf
object x x = {1234356.7890, 3.1415, 2}
for i = 1 to length(x) do  -- convert numbers to strings "in place"
x[i] = sprintf("%g",x[i]) -- replace the %g with %8.2f or whatever format u like
end for
? length(x[2]) puts(1, x[2])
 --
Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: numbers to text

Thanks Irv
Regards
Bob
----- Original Message -----
From: irv <irv at ELLIJAY.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Wednesday, August 30, 2000 10:34 PM
Subject: Re: numbers to text


> On Wed, 30 Aug 2000, you wrote:
> > I have a sequence of many floating point numbers.
> > I would like to check the length of each of them using getTextExtent() but
> > text data is required by this function and I am
getting a
> > type check error when I use sequence[n].
> > If I include the variable assigned to sequence[n] in quotation marks it will
> > print the name of the variable.. How do I change
the
> > value of the variable into text notation. ie what's the Euphoria equivalent
> > of the basic STR$() function.
> > I've read the sequence doc. and the examples for string literals are there
> > but I can't find anything for string variables.Thanks
in
> > advance.
> > Regards
> > Bob
>
> -- see sprintf
> object x x = {1234356.7890, 3.1415, 2}
> for i = 1 to length(x) do  -- convert numbers to strings "in place"
> x[i] = sprintf("%g",x[i]) -- replace the %g with %8.2f or whatever format u
> like
> end for
> ? length(x[2]) puts(1, x[2])
>  --
> Regards,
> Irv

new topic     » goto parent     » topic index » view message » categorize

5. Re: numbers to text

Thanks Lewis.
Regards
Bob
----- Original Message -----
From: Lewis Townsend <keroltarr at HOTMAIL.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Wednesday, August 30, 2000 8:47 PM
Subject: Re: numbers to text


> Hello Bob,
>
> >I have a sequence of many floating point numbers.
> >I would like to check the length of each of them using getTextExtent() but
> >text data is required by this function and I am getting a
> >type check error when I use sequence[n].
> >If I include the variable assigned to sequence[n] in quotation marks it
> >will print the name of the variable.. How do I change the
> >value of the variable into text notation. ie what's the Euphoria equivalent
> >of the basic STR$() function.
> >I've read the sequence doc. and the examples for string literals are there
> >but I can't find anything for string variables.Thanks in
> >advance.
> >Regards
> >Bob
>
> I think what you want is the sprint() function in misc.e
> example:
>
> include misc.e
> atom num
> sequence text
> num = 15.1976
> text = sprint (num) -- text is now "15.1976"
> ? length (text) -- will print 7
>
> later,
> Lewis Townsend
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu