realbasic-nug
[Top] [All Lists]

Re: Need help with a runtime error

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Need help with a runtime error
From: Kevin Rudman <kevin dot rudman at ntlworld dot com>
Date: Wed, 27 Feb 2002 20:25:55 +0000
on 27/2/02 7:21 pm, Terry Hulseberg at RB at Hulseberg dot com wrote:
 
> Dim i As Integer
> 
> For i = WindowCount downTo 1
>     window(WindowCount-1).close
> next

Perhaps better to do:

  Dim i, n As Integer
  
  n = WindowCount-1
  For i = n DownTo 0
    window(i).close
  Next 


That way you evaluate WindowCount once only and avoid tinkering with the
loop count evaluation from within the loop, which makes things clearer, if
not less dangerous too!

Kevin Rudman



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