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 X-Google-Thread: 103376,866f55656f224cc8,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-15 18:49:48 PST Date: Mon, 16 Feb 2004 10:43:36 +0800 From: Cecilia Chew User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Question from newbie Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 219.95.190.199 X-Original-NNTP-Posting-Host: 219.95.190.199 Message-ID: <40302ec4$1_2@news.tm.net.my> X-Trace: news.tm.net.my 1076899524 219.95.190.199 (16 Feb 2004 10:45:24 +0800) Organization: TMnet Malaysia Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!wn14feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!news1.tm.net.my Xref: archiver1.google.com comp.lang.ada:5587 Date: 2004-02-16T10:43:36+08:00 List-Id: Hi all, I'm still in learning Ada. However, there were something missing in coding. Could someone point out my problems. Just take an example, i'm now doing a program that ask user input x characters and program will sort the user's input into ascending order. The is below: ======================================================================== with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_io; procedure Sort is subtype Index is Integer range 1 .. 10; subtype Char is Character range 'a' .. 'z'; type Str is array (Index) of Char; procedure Ascending (Left : in out Character; Right : in out Character); procedure Ascending (Left : in out Character; Right : in out Character) is Left : Character; Right : Character; Temp : Character; begin if Left > Right then Temp := Left; Left := Right; Right := Temp; end if; end Ascending; Num : Index; Input : Str; begin Put ("Please enter the number of character : "); Get (Num); New_Line; if Num not in Index then Put ("Please enter 1 to 10 characters only!"); else Put ("Please enter" & Integer'Image(Num) & " characters : "); for num in Index loop Get (Input (Num)); if Input'Length = num then for I in 1 .. num loop Ascending_char (Input(i), Input(i+1)); end loop; while not End_Of_Line loop Put (Input(Num)); end loop; else exit; end if; end loop; end if; end Sort; ============================================================================= Question: 1. As the procedure ascending compiles as a independent unit with the other file name, it could sort the two characters correctly. However, as I put it together with sort.adb program. Specification part that declared the procedure ascending conflict with the variable left and right. Where is the mistake? 2. Before plug in the procedure ascending, the program successfully being compiled. But the program can't allocate the specified space as x characters in outputting the result. For an example, user specified 2 characters, but the program still allow user to input less than or excess 2 characters..Where is the mistakes? 3. From my coding, what should I pay more attention to? Please kindly give me any comments.. Regards, -- Cecilia -- Cecilia Chew c e c i l i a g r e e n l i m e . c o m