Re: for loop (c-lang)



On Wed, 28 Feb 2007 14:26:31 GMT, erewhon@xxxxxxxxxx (J French)
waffled on about something:

On Wed, 28 Feb 2007 12:43:12 +0000, Dodgy
<Dodgy@xxxxxxxxxxxxxxxxxxxxx> wrote:

<snip>

Well it might be in Delphi, not sure, can honestly say if I've ever
tried to do a loop zero times in a for, but from the programming
background I come from "for" and "repeat" loops have the comparison at
the end, a "while" has it at the beginning.

I guess I'll have to blow the dust of my asm programming and see what
Delphi pumps out.

Steve, I hope your ants are still marching :-}

*waves* They ate my lunch and mutated... One day I might actually get
round to finishing that project! lol!

For N := 2 To 1 Do

will not execute the loop, although in early versions of BASIC I have
heard that it did. I can't remember.

PC BBC BASIC Version 4.61 #300495
by Richard Russell, Jeffrey Raynor and Brandon Butterworth
(C) Copyright R.T.Russell 1987
>10 FOR L=2 TO 1
>20 PRINT L
>30 NEXT
>RUN
2
>

I knew I'd be glad I kept that exe on my PC one day! I'm impressed I
managed to write it without putting a single semi-colon on the end of
a line!

The real thing is that 'C' has its own rules and being supremely
illegible the OP that managed to post in a totally inappropriate group
failed to see that the expression in Delphi evaluates to :

For N := 0 To 0 Do

And it is pretty obvious that it will do its thing once.

Aye, tis a silly language, let us talk of it no more!

Dodgy.
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES
.


Quantcast