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 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-12 19:40:12 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!cyclone1.gnilink.net!attbi_feed3!attbi.com!attbi_s51.POSTED!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: <4d01ad29.0312120149.ddda940@posting.google.com> Subject: Re: Word counting X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: NNTP-Posting-Host: 12.211.58.135 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s51 1071286811 12.211.58.135 (Sat, 13 Dec 2003 03:40:11 GMT) NNTP-Posting-Date: Sat, 13 Dec 2003 03:40:11 GMT Organization: Comcast Online Date: Sat, 13 Dec 2003 03:40:11 GMT Xref: archiver1.google.com comp.lang.ada:3432 Date: 2003-12-13T03:40:11+00:00 List-Id: "wave" wrote in message news:4d01ad29.0312120149.ddda940@posting.google.com... > Hello again, christ six replies already :) > > Anyway, I've taken most of your advice and I've rethought the pseudo > code for the program. > > While not the end of the file > Read the next line from the file > Move the cursor one place and if character is within a..Z boundaries > that character is stored in an array word_length(number) for that word > length > if the chracter is a space, then we've hit the end of that word > length so increment our word length to search for by 1 (number). we've > also hit the end of a word to increment our word count. > End of loop; > Here's the way I would pseudo code this (I don't think yours quite works). While its not the end of the file Read a line from the file Initialize "current number of characters in word" to 0 For each character in the line loop If a character is a space If the current number of characters in word is > 0 Increment the length count using the current number of characters in word Set the current number of characters in word to 0 End If else Increment the current number of characters in word end if End Loop If the current number of characters in word is > 0 Increment the length count using the current number of characeter in word End If End While I coded this logic in Ada and it appears to work. Your original code didn't initialize the array of counts (GNAT warned about this). BTW: This was more of an algorithm question than an Ada question. I'll leave the coding up to you. Steve (The Duck) > > I realise this is a complete mess and I'm thinking about scrapping the > whole thing and starting again. For some reason I'm not managing to > get my head around it and I'm unsure why. > > I appreciate your patience up to this far. > > Cheers again, > Mut.