home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!poly-vlsi!music.mus.polymtl.ca
- From: CT80@music.mus.polymtl.ca (Steph)
- Newsgroups: comp.lang.pascal
- Subject: RE: Why doesn't this cause an error?
- Message-ID: <03JAN93.21792946.0032@music.mus.polymtl.ca>
- Date: 4 Jan 93 01:10:43 GMT
- References: <1993Jan01.220029.27699@crash>
- Sender: usenet@music.mus.polymtl.ca
- Organization: Ecole Polytechnique de Montreal
- Lines: 31
-
- In article <1993Jan01.220029.27699@crash> tech@crash.cts.com (Don Bontemps) writes:
- >I know there is probably an easy answer to this question, but here is
- >a portion of a routine that I am using to convert a lowercase string
- >into an uppercase string.
- >
- >
- > readln(comment);
- > for l := 1 to length of comment do comment[l] := upcase(comment[l]);
- >
- >
- >
- >If the user doesn't enter anything, this causes the length of comment to
- >become zero and what confuses me is that this event does not cause any
- >error whatsoever. I would figure that "for l := 1 to 0" to cause a
- >run-time error or some other type of error, but it doesn't. Why not??
- >
- >
- >.
- >.
-
- Someone probably answered this one already, but anyway, here goes..
-
- The FOR loop checks the condition before doing the statement. Since
- you have a loop from 1 to 0, well it goes something like this ..
-
- for l := 1 to 0 do ..
-
- 1st run -> (l := 1) > 0, so it gets out of the loop right away.
- Makes sense?
-
- Steph.
-