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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,97643ec695b9bf73,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-11 14:01:08 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mutilation@bonbon.net (wave) Newsgroups: comp.lang.ada Subject: Word counting Date: 11 Dec 2003 14:01:07 -0800 Organization: http://groups.google.com Message-ID: <4d01ad29.0312111401.32ec5297@posting.google.com> NNTP-Posting-Host: 62.252.128.11 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1071180068 9178 127.0.0.1 (11 Dec 2003 22:01:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 11 Dec 2003 22:01:08 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:3398 Date: 2003-12-11T14:01:07-08:00 List-Id: Hello, been following this newsgroup for a few months now and I can tell it's a great place for help judging by some of the threads I've been reading. I'm extremely new to ada after coding in a handful of newer languages such as PHP and the like. I'm having some difficulties with a program I am trying to design using the various functions available to me. The program is this: I'm trying to read a file of which each sentence consists of a line of words, separated obviously by one or more blank spaces. I'm trying to get it to read these lines of the file and count the number of words that have one letter, two letters, and so on, up to a maximum of fifteen letters. I'm actually having loads more difficulty than I thought with a 'case' designed version of the program, although I have now changed that to loops as, to me, it looks much 'cleaner'. I've got the following code so far, I'm wondering if anyone could be of assistance and tell me whats up with it. Max_Chars : Integer := 100; Max_Words : constant Integer := 15; Max_Word_Len : constant Integer := 20; Position, Number : Integer := 1; Length, Counted_Words : Integer := 0; Current_Line : String (1 .. Max_Chars); type Words_Of_Length is array (Integer range 1 .. 10) of Integer; type Word_Count_Line is array (Integer range 1 .. 10) of Integer; Word_Count : Word_Count_Line; Word_Length : Words_Of_Length; begin while (not End_Of_File) loop Position := 1; Get_Line(Current_Line,Length); for Position in 1..Length loop if (Current_Line(Position) = ' ') then Word_Length(Number) := Word_Length(Number) + 1; Number := Number + 1; Counted_Words := Counted_Words + 1; end if; Put(Current_Line(Position)); end loop; end loop; Put("Counted words: " & Integer'Image(Counted_Words)); New_Line(5); for Index in 1..10 loop Put(Integer'Image(Index) & " " & Integer'Image(Word_Length(Index))); New_Line; end loop; New_Line(5); end; I appreciate any feedback you could give me on this, as it's really been annoying me. Cheers, Mut.