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: Charles Yeomans <yeomans at desuetude dot com>
Date: Sun, 30 Dec 2001 13:25:13 -0500

On Friday, December 28, 2001, at 07:36  PM, Kevin Ballard wrote:

On 12/28/01 7:15 PM, "Charles Yeomans" <yeomans at desuetude dot com> wrote:

In such situations, it's preferable to use a While...Wend or Do..Loop
construction, I think.

Why? All three loops have to evaluate the UBound(), and when parsing a
dynamically-changing array, the For loop is best because you get the
incremented counter. There's no reason at all to use a While...Wend or
Do...Loop


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?

Charles Yeomans




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