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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,97643ec695b9bf73 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-11 18:41:35 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!fr.ip.ndsoftware.net!teaser.fr!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: ada_wizard@toadmail.com Newsgroups: comp.lang.ada Subject: Re: Word counting Date: Thu, 11 Dec 2003 21:39:37 -0500 Organization: Cuivre, Argent, Or Message-ID: NNTP-Posting-Host: lovelace.ada-france.org X-Trace: melchior.cuivre.fr.eu.org 1071196774 34340 80.67.180.195 (12 Dec 2003 02:39:34 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Fri, 12 Dec 2003 02:39:34 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.3 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:3404 Date: 2003-12-11T21:39:37-05:00 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 mutilation@bonbon.net (wave) writes: > 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. Welcome to the One True Language :). > 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. > > Max_Chars : Integer := 100; > Max_Words : constant Integer := 15; > Max_Word_Len : constant Integer := 20; These make sense. > Position, > Number : Integer := 1; > Length, > Counted_Words : Integer := 0; These too. > 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; Now you've lost me. What is stored in Word_Length (1)? the number of words of length one? It will help you (as well as me) to say that in a clear comment. > begin > > while (not End_Of_File) loop the parens are not necessary, and give away that you are used to C :). > 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; Since this logic does not depend on Position, I can't see that it does anything useful. > > > I appreciate any feedback you could give me on this, as it's really > been annoying me. What does it do that you did not expect? I know "it doesn't work", but can you be more specific? Show an example input, and say what output you expected. Process the example input yourself, following your code. That will help you figure out what it should do, and why it isn't doing it. In general, your code is fairly good style. Hope to hear more from you, -- -- Stephe ___________________________________________________________ This mail sent using ToadMail -- Web based e-mail @ ToadNet