comp.lang.ada
 help / color / mirror / Atom feed
From: "C. Bauman" <cbauman@impulse.net>
Subject: Re: an infinate loop
Date: Fri, 13 Jul 2001 09:48:36 -0700
Date: 2001-07-13T09:48:36-07:00	[thread overview]
Message-ID: <3b4f259b$0$192@news.impulse.net> (raw)
In-Reply-To: tks6i2llqcla15@corp.supernews.com

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" <beau@hiwaay.net> 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.





      parent reply	other threads:[~2001-07-13 16:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-12 21:43 an infinate loop Beau
2001-07-13  3:21 ` DuckE
2001-07-13 13:57 ` Ted Dennison
2001-07-13 17:01   ` Jeffrey Carter
2001-07-13 18:11     ` Ted Dennison
2001-07-13 22:26       ` Jeffrey Carter
2001-07-16 15:14         ` Marin David Condic
2001-07-17 17:02           ` Matthias Kretschmer
2001-07-17 17:56             ` Marin David Condic
2001-07-17 19:25               ` Ted Dennison
2001-07-19 11:38                 ` Matthias Kretschmer
2001-07-19 14:28                   ` Ted Dennison
2001-07-17 17:13           ` Warren W. Gay VE3WWG
2001-07-14 23:41       ` Darren New
2001-07-16 13:24         ` Ted Dennison
2001-07-16 15:19           ` Marin David Condic
2001-07-13 20:40     ` chris.danx
2001-07-13 22:29       ` Jeffrey Carter
2001-07-14 14:00         ` Robert Dewar
2001-07-14 16:17           ` Negative Logic (was: Re: an infinate loop) Jeffrey Carter
2001-07-17  4:06             ` Robert Dewar
2001-07-17  4:23             ` Robert Dewar
2001-07-16  9:26           ` an infinate loop Philip Anderson
2001-07-19  9:32             ` an infinite [was: infinate] loop AG
2001-07-15 21:18   ` an infinate loop Matthias Kretschmer
2001-07-16 21:59   ` Stephen Leake
2001-07-13 16:48 ` C. Bauman [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox