Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!usenet.eel.ufl.edu!news-feed-1.peachnet.edu!darwin.sura.net!gatekeeper.es.dupont.com!esds01.es.dupont.com!news
From: boettgjt@ldoc01.lvs.dupont.com (John Boettger)
Subject: Re: writing numbers to a string
Message-ID: <1995Mar10.134348.20121@es.dupont.com>
Sender: news@es.dupont.com (USENET News System)
Nntp-Posting-Host: mcclanc.wm.dupont.com
Organization: Dupont Company
X-Newsreader: WinVN version 0.80
References: <D50tur.1K4@festival.ed.ac.uk> <3jhcp1$6o8@sgi.iunet.it>
Date: Fri, 10 Mar 1995 13:43:48 GMT
Lines: 37

In article <3jhcp1$6o8@sgi.iunet.it>, "Nik, Zordan Nicola A. G." <mc2074@mclink.it> says:
>
>olly@festival.ed.ac.uk (O Morgan) wrote:
>>
>> I want to 'convert' an integer into string form.  
>> Something like 
>>       aString := anInteger asString.
>> Eg: in 'C', the equivalent of 
>>       sprintf("string text %d bit more %f",x,y);
>> 
>> I've tried WriteStreams (nextPut:, nextPutAll:, nextTwoBytesPut:, etc),
>> no joy.
>> 
>
>If you want rightly print data on a string try:
>
>   | n s |  
>   n:= 1566.
>   s := String new asStream.
>   s := n printOn: s.
>   "here you can print anything inside the stream s on a string"   
>   s := s contents.   "to get the written data in string form"
>
>Hope this helps.   
>
>
>Bye, Nik.

a similar solution for VisualWorks users would be...

  | n s |
  n := 1566.
  s := String new writeStream.
  n printOn: s.
  ^s contents

regards, -John F.
