1. Integer to String
Hi to everyone, happy new year!
I'm actually working on a demo of a battle of my RPG, so I neede a routine
to convert an integer to a string, the way I found was this, but if anyone
knows a faster way, please, send me. Thank you
-- Code starts here
global function int_to_str(atom data)
sequence to_return
integer temp,length
atom filenumber
if data>=0 then
if data<=9 then
length=1
end if
end if
if data>=10 then
if data<=99 then
length=2
end if
end if
if data>=100 then
if data<=999 then
length=3
end if
end if
if data>=1000 then
length=4
end if
to_return={}
filenumber=open("temp.tmp","w")
print(filenumber,data)
close(filenumber)
filenumber=open("temp.tmp","r")
for times=1 to length do
temp=getc(filenumber)
to_return=append(to_return,temp)
temp=0
end for
close(filenumber)
system("del temp.tmp",2)
return to_return
end function
2. Re: Integer to String
>Hi to everyone, happy new year!
>I'm actually working on a demo of a battle of my RPG, so I neede a routine
>to convert an integer to a string, the way I found was this, but if anyone
>knows a faster way, please, send me. Thank you
Eh.. lookup the library routine value () in get.e
Example:
my_integer = value("234")
..or..
my_object = value (" { /" Testing /" , 4, 45.345, { 3423, 'D' } "}
Easy, huh ?
But don't forget to include get.e first.
Ralf
3. Re: Integer to String
On Mon, 5 Jan 1998, Ralf Nieuwenhuijsen wrote:
> >Hi to everyone, happy new year!
> >I'm actually working on a demo of a battle of my RPG, so I neede a routine
> >to convert an integer to a string, the way I found was this, but if anyone
> >knows a faster way, please, send me. Thank you
>
> Eh.. lookup the library routine value () in get.e
>
> Example:
>
> my_integer = value("234")
>
> ..or..
>
> my_object = value (" { /" Testing /" , 4, 45.345, { 3423, 'D' } "}
er Ralf, he asked for an INTEGER TO A STRING, not a STRING to an INTEGER.
Geez. Please READ a message before responding to it and making everyone
think you're an idiot. =)
To convert an integer (or any other atom) to a sequence use sprintf(s,n)
where s1 is the string format and n the number you want converted.
seq="You have "&sprintf("%6d",235)&" gold pieces."
puts(1,seq) will give:
You have 000235 gold pieces.
Michael
4. Re: Integer to String
Well, thanks to everyone that answered my question!
Ralf, I think that you haven't understood my idea, it was to turn an integer
to a string, the value command will turn a string value into a integer, but
thanks anyway, at least you tried to explain me
Jiri, the sprintf could display a string like an integer, but to my code I
think that my solution will be good by now, thanks to you too!
Hope a playable battle demo soon!
Eduardo Uemura Okada
e-mail: cool at mii.nutecnet.com.br
5. Re: Integer to String
>On Mon, 5 Jan 1998, Ralf Nieuwenhuijsen wrote:
>
>> >Hi to everyone, happy new year!
>> >I'm actually working on a demo of a battle of my RPG, so I neede a
routine
>> >to convert an integer to a string, the way I found was this, but if
anyone
>> >knows a faster way, please, send me. Thank you
>>
>> Eh.. lookup the library routine value () in get.e
>>
>> Example:
>>
>> my_integer = value("234")
>>
>> ..or..
>>
>> my_object = value (" { /" Testing /" , 4, 45.345, { 3423, 'D' } "}
>
>er Ralf, he asked for an INTEGER TO A STRING, not a STRING to an INTEGER.
>Geez. Please READ a message before responding to it and making everyone
>think you're an idiot. =)
Oops..
Well, integer to string, string to integer .. it's almost the same.
And in the documentation, it says: " See also: sprintf "
(or at least is should say that)
Come on, I can make a mistake, I'm living on cafeine now, because I don't
have time to sleep any more.
Ralf
6. Integer to String
Hi all, I am sending a little function to perform an integer-to-string
convertion.
No, I am sure, the value function can perform a string-to-integer, this
one makes the reverse way.
Sometime past I wrote to this list asking for something like this,
because I needed to write to the disk and read with getc to convert to a
string, now It does in a mathematic way (or something like), I don't know if
it will be useful, it can convert values from 1 to 999.
Bye.
Eduardo Uemura Okada
e-mail: cool at mii.nutecnet.com.br
begin 666 inttostr.txt
M?0T*#0H)9FQA9U]S<#$], T*#0H):68@9&%T83X],3 P('1H96X-"@D):68@
M9&%T83PQ,# P('1H96X-"@D)"69L86=?<W Q/3$-"@D)"7-T<FEN9SUA<'!E
M;F0H<W1R:6YG+&9L;V]R*&1A=&$O,3 P*2D-"@D)"61A=&$]9&%T82TH9FQO
M;W(H9&%T82\Q,# I*C$P,"D-"@D)96YD(&EF#0H)96YD(&EF#0H):68@9FQA
M*0T*"0D)<W1R:6YG/6%P<&5N9"AS=')I;F<L9&%T82D-"@D)"61A=&$], T*
M,"DJ,3 I#0H)"0ES=')I;F<]87!P96YD*'-T<FEN9RQD871A*0T*"0D)9&%T
M"7-T<FEN9SUA<'!E;F0H<W1R:6YG+&9L;V]R*&1A=&$O,3 I*0T*"0D)9&%T
M<W1R:6YG+&1A=&$I#0H)"0ED871A/3 -"@EE;F0@:68-"@EI9B!D871A/CTQ
#:6]N
`
end
7. Re: Integer to String
Eduardo Uemura Okada wrote:
>
> Hi all, I am sending a little function to perform an integer-to-string
> convertion.
> No, I am sure, the value function can perform a string-to-integer, this
> one makes the reverse way.
> Sometime past I wrote to this list asking for something like this,
> because I needed to write to the disk and read with getc to convert to a
> string, now It does in a mathematic way (or something like), I don't know if
> it will be useful, it can convert values from 1 to 999.
> Bye.
i've got an easier way
sequence s
integer i
i = 5
s = sprintf("%d", i)
? s -- prints "5"
--
. m i k e b u r r e l l .
. http://mikpos.home.ml.org . ftp://ftp.scene.org/pub/music/artists/mikpos/ .
. m i k p o s @ s o f t h o m e . n e t .
. m i k p o s 1 9 9 8 .
8. Re: Integer to String
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
Mar 21, 1998
-
Last edited Mar 22, 1998
-----Original Message-----
From: Eduardo Uemura Okada <cool at MII.NUTECNET.COM.BR>
To: Multiple recipients of list EUPHORIA <EUPHORIA at MIAMIU.ACS.MUOHIO.EDU>
Date: zaterdag 21 maart 1998 18:39
Subject: Integer to String
| Hi all, I am sending a little function to perform an integer-to-string
|convertion.
| No, I am sure, the value function can perform a string-to-integer, this
|one makes the reverse way.
| Sometime past I wrote to this list asking for something like this,
|because I needed to write to the disk and read with getc to convert to a
|string, now It does in a mathematic way (or something like), I don't know
if
|it will be useful, it can convert values from 1 to 999.
| Bye.
Value will handle any object, sequence, atom, etc.
THe other way around for just an integer is offcourse sprintf. (see
library.doc)
If you want one that handles sequences, and atoms as well, you're could use
one of the extra goodies from RDS, it's on their archive page.
If you want to save and load an integer or sequence, or atom, or any kind of
object, to disk with good efficiency.. try EDOM2 (bug free version out
tomorrow..)
--Ralf
9. Re: Integer to String
At 08:13 PM 3/21/98 +0100, Ralf wrote:
try EDOM2 (bug free version out tomorrow..)
>
Tomorrow?!
Can we get Ralf a job with Microsoft?
Irv
------------------------------------------------------
Visit my Euphoria programming web site:
http://www.mindspring.com/~mountains
------------------------------------------------------
10. Re: Integer to String
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
Mar 21, 1998
-
Last edited Mar 22, 1998
Irv commented:
|At 08:13 PM 3/21/98 +0100, Ralf wrote:
| try EDOM2 (bug free version out tomorrow..)
|>
|Tomorrow?!
|Can we get Ralf a job with Microsoft?
The bugs are already out, but the docs need to updated a bit, and I will
write a couple more example programs and stuff.
I could off course release a new version after every bug fix or update I do,
but wouldn't that be a lot more annoying to every1 ?? (Esspecially to Robert
and you Irv, but also to all who actually use it and have to download it
again)
Are there people using this ? Or at least find this usefull ?
--Ralf
11. Re: Integer to String
- Posted by Arthur Adamson <euclid at ISOC.NET>
Mar 21, 1998
-
Last edited Mar 22, 1998
At 02:29 PM 3/21/98 -0500, you wrote:
>At 08:13 PM 3/21/98 +0100, Ralf wrote:
> try EDOM2 (bug free version out tomorrow..)
>>
>Tomorrow?!
>Can we get Ralf a job with Microsoft?
>
>Irv
>------------------------------------------------------
>Visit my Euphoria programming web site:
>http://www.mindspring.com/~mountains
>------------------------------------------------------
IMHO, if we can, it will greatly improve the quality of Microsoft
software!!
Art
Arthur P. Adamson, The Engine Man, euclid at isoc.net
12. Re: Integer to String
At 10:49 PM 3/21/98 -0500, The Engine Man wrote:
>>At 08:13 PM 3/21/98 +0100, Ralf wrote:
>> try EDOM2 (bug free version out tomorrow..)
>>>
>>Tomorrow?!
>>Can we get Ralf a job with Microsoft?
> IMHO, if we can, it will greatly improve the quality of Microsoft
>software!!
> Art
Not only that, but they might get Windoz 98 working before
the year 2000!
(When all the other software quits working.)
Irv
------------------------------------------------------
Visit my Euphoria programming web site:
http://www.mindspring.com/~mountains
------------------------------------------------------