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-Thread: 103376,3f1374bc66d2dc03 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada Subject: Re: creating an array Date: 15 Feb 2006 19:09:07 -0800 Organization: http://groups.google.com Message-ID: <1140059347.793793.135880@g44g2000cwa.googlegroups.com> References: <1139897171.996297.230070@z14g2000cwz.googlegroups.com> <1139951664.264622.240870@z14g2000cwz.googlegroups.com> <1139955455.397334.310790@g43g2000cwa.googlegroups.com> <878xsd8sqq.fsf@ludovic-brenta.org> <1139957691.430522.159580@o13g2000cwo.googlegroups.com> <874q318rkd.fsf@ludovic-brenta.org> <1139960269.338824.166090@g14g2000cwa.googlegroups.com> <87u0b070gl.fsf@ludovic-brenta.org> <1140046148.803154.70980@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: 69.170.89.0 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1140059353 13883 127.0.0.1 (16 Feb 2006 03:09:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 16 Feb 2006 03:09:13 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=69.170.89.0; posting-account=SqOfxAwAAAAkL81YAPGH1JdBwpUXw9ZG Xref: g2news1.google.com comp.lang.ada:2914 Date: 2006-02-15T19:09:07-08:00 List-Id: Now that you have a complete program, here is the solution I was thinking of. with Ada.Text_Io; procedure Sort_Digits is procedure Sort_Characters (Buffer : in out String) is Exchanged : Boolean; Temp : Character; begin loop Exchanged := False; for I in Buffer'First..Buffer'Last - 1 loop if Buffer(I) > Buffer(I + 1) then Temp := Buffer(I + 1); Buffer(I + 1) := Buffer(I); Buffer(I) := Temp; Exchanged := True; end if; end loop; exit when not Exchanged; end loop; end Sort_Characters; Input_String : String(1..10); Length : Natural; begin Ada.Text_Io.Put_Line("Enter a number of no more than 10 digits"); Ada.Text_Io.Get_Line(Item => Input_String, Last => Length); Sort_Characters(Input_String(1..Length)); Ada.Text_Io.Put_Line(Input_String(1..Length)); end Sort_Digits; Note that there is only one input, the number to be sorted. The resulting output matches your program requirements. There can never be a mis-match between stated and actual sizes of the input string. There is no need to raise an exception due to parameter inconsistencies. Jim Rogers