From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8bb44fc57f6db2f2 X-Google-Attributes: gid103376,public From: reason67@my-deja.com Subject: Re: Number into String Date: 2000/01/06 Message-ID: <852k73$4p7$1@nnrp1.deja.com>#1/1 X-Deja-AN: 569043390 References: <8517up$t0m$1@green.kreonet.re.kr> <851a0e$tp7$1@green.kreonet.re.kr> <852crn$umf$1@nnrp1.deja.com> <852dmq$vad$1@nnrp1.deja.com> X-Http-Proxy: NetCache@www-blv-proxy4.boeing.com: Version NetApp Release 3.4D6: Mon Aug 23 16:40:19 PDT 1999-Solaris, 1.0 x30.deja.com:80 (Squid/1.1.22) for client 12.13.226.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Jan 06 17:43:03 2000 GMT X-MyDeja-Info: XMYDJUIDreason67 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.05 [en]C-Boeing Kit (Win95; I) Date: 2000-01-06T00:00:00+00:00 List-Id: In article <852dmq$vad$1@nnrp1.deja.com>, Robert Dewar wrote: > In article <852crn$umf$1@nnrp1.deja.com>, > reason67@my-deja.com wrote: > > In article <851a0e$tp7$1@green.kreonet.re.kr>, > > "Jeong, Lae Hyung" wrote: > > > I've found !! > > > > > > S : String := Integer'Image(NUM); > > > > This thread is kinds fortunate for me to ask a question. I > often have > > the case where I need to put a number into a string of fixed > length. > > So use the facilities in Text_IO! Can't do that. The reason why is stated in the last line of the comment I supplied at the beginning of my procedure: -- If -- the length of Number String is greater than the Length -- provided, the left most portion of the Number that can fit -- in the result is returned. -- Text_IO returns a layout_error in this case. ---------- ---------- with Ada.IO_Exceptions; with Ada.Text_IO; procedure Aaa_Test_It is package Int_IO is new Ada.Text_IO.Integer_IO (Integer); Number : Integer := 5000; Str1 : String (1 .. 3); begin Int_IO.Put (To => Str1, Item => Number); Ada.Text_IO.Put_Line (Str1); exception when Ada.IO_Exceptions.Layout_Error => Ada.Text_IO.Put_Line ("Str1 will not work"); end Aaa_Test_It; I could do the text_io on a larger string than is required and then copy it into the smaller string, but that is essentially the same thing as I am doing with the 'image so it does not gain me anything. --- Jeffrey Blatt Sent via Deja.com http://www.deja.com/ Before you buy.