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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.karotte.org!news.musoftware.de!wum.musoftware.de!news.tornevall.net!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Conversions Date: Mon, 26 Oct 2009 13:09:45 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <4acc8c20$0$284$14726298@news.sunsite.dk> <4acdb7aa$0$283$14726298@news.sunsite.dk> <1256585268.3272.14.camel@HERMES> NNTP-Posting-Host: 6c524428f5f39bea1fab5f28f96d0c04 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: 98fe7d79fa21c59a93d90906d4bda0bb X-Complaints-To: abuse@tornevall.net X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: <1256585268.3272.14.camel@HERMES> X-Validate-Post: http://news.tornevall.net/validate.php?trace=98fe7d79fa21c59a93d90906d4bda0bb X-SpeedUI: 1738 X-Complaints-Italiano: Parlo la lingua non � italiano User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) X-Posting-User: 9b22bfe2855937f9b3faeec7cfc91295 Xref: g2news2.google.com comp.lang.ada:8797 Date: 2009-10-26T13:09:45-07:00 List-Id: Bruno wrote: > > I have a little problem with a function that "convert" a date, that is a > record type, into a string. To do this I'm using "image" attribute how > can you see in the following code > > http://paste.ideaslabs.com/show/5KEJUGcDF > > but when run the program and the function is executed a get an > "constraint error". The compiler show me a message that say that the > size is too long but I don't know what to do. 'Image for an integer type returns the shortest string necessary to represent the value, with ' ' added to the front for a positive value and '-' for a negative value. Thus we can get 6 => " 6" -6 => "-6" 10 => " 10" -10 => "-10" For your application (date image), 2-digit day and month numbers are likely; their 'Image will not fit in 2 characters. You can save the 'Image and decide what to do with it: declare Day_Image : constant String := Integer'Image (F.Dia); begin if F.Dia < 10 then S (1) := '0'; S (2) := Day_Image (Day_Image'Last); else S (1 .. 2) := Day_Image (Day_Image'Last - 1 .. Day_Image'Last); end if; end; You can also look at the operations in Ada.Text_IO.Integer_IO that write to a String parameter. -- Jeff Carter "We call your door-opening request a silly thing." Monty Python & the Holy Grail 17