realbasic-nug
[Top] [All Lists]

Re: Files I don't want to see!

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Files I don't want to see!
From: Kevin Ballard <kevin at sb dot org>
Date: Sun, 30 Dec 2001 14:01:59 -0500
On 12/30/01 1:25 PM, "Charles Yeomans" <yeomans at desuetude dot com> wrote:

> In fact there is.  Using a For...Next loop for such situations is a
> well-known source of programming errors; I think this is mentioned in
> "Code Complete", and there have been numerous "help me" messages on this
> list in which the problem is caused by using a For..Next loop like this.
> 
> Consider the following code.
> 
>  For i = 0 to WindowCount - 1
>    Window(i).Close
>  Next
> 
> Will this close all windows?

I still think it's easier to say:

  For i = WindowCount - 1 DownTo 0
    Window(i).Close
  Next

instead of:

  Do
    Window(0).Close
  Loop until WindowCount = 0

--
Kevin Ballard
kevin at sb dot org
http://kevin.sb.org/



<Prev in Thread] Current Thread [Next in Thread>