Dilwyn Jones writes

<>
> In my programs I tend to put a catch-all in for cases like this which 
> allows this case to go around the loop again, but also to exit the 
> loop if exhausted:
> 
> 9476 IF dv_start <= 1 THEN NEXT i : EXIT i
> 
> The exit gets ignored unless the loop is exhausted. Not sure if it's 
> good programming style, but it does seem to work.

Not only does it work, but if you use NEXT without a subsequent EXIT, 
as Dilwyn correctly has done, it is unlikely to work in the way the 
casual programmer might expect.

In Duncan's program you could have just had

9476 IF dv_start <= 1 THEN NEXT i
9478 END FOR i

but this is bad programming practise as at some later time you might 
forget that the two lines belonged together and introduce new lines or 
changes, thus unnoticed subtly altering the logic of the program and 
creating a possible nightmare bug hunt for the future.

Per
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to