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,cf677878aa77e0d8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-13 10:09:14 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!sienna.impulse.net!azure.impulse.net!not-for-mail From: "C. Bauman" Newsgroups: comp.lang.ada References: Subject: Re: an infinate loop Date: Fri, 13 Jul 2001 09:48:36 -0700 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <3b4f259b$0$192@news.impulse.net> NNTP-Posting-Host: 207.154.66.183 X-Trace: azure.impulse.net 995042715 192 207.154.66.183 Xref: archiver1.google.com comp.lang.ada:9915 Date: 2001-07-13T09:48:36-07:00 List-Id: If you consider that detecting end-of-line is to be equivalent to detecting a space character, I think you'll find that loop is inappropriately placed. Since you don't specify how the infinite loop manifests itself, I can't guarantee this will fix it, but it should help if I point out that you only need one loop for this. Most of what you are doing with loops can be handled in the case statement. i.e. in pseudo code: main loop exit on eof if eol then letter = ' ' else letter = get(char) case letter 'A'..'z' - update wordlength ' ' - update wordcount of wordlength, reset wordlegnth '.','?','!' - output sentence data, reset wordcounts, reset wordlength end case end loop if sentence not terminated correctly, output remaining sentence data. I'm not sure how much Ada programming you've had, but using arrays and subprocedures can reduce the typing and keep the listing readable. -CB "Beau" wrote in message news:tks6i2llqcla15@corp.supernews.com... > Hey I am in an infinate loop and don't understand why. here is my problem to > understan exactly what is going down: > assume that a set of sentences is to be processed. Each sentence consists of > a sequence of words, seperated by one or more blank spaces. Write a program > that will read these sentences and count the number of words that have one > letter, two letter, and so on, up to ten letters. > It was working until I put in a loop to catch the end of line because if the > sentence was more than a line, then the words on the end would be counted > together. now the program does the first line perfect and then falls into > the "never-ending" loop. enclosed is the adb file and the data file. put the > file anywhere just type the path in when asked. listing snipped.