[EMAIL PROTECTED] wrote:
Subject: Re: Two times Dim values without warning
From: [EMAIL PROTECTED]
Date: Wed, 3 May 2006 08:17:24 -0600

On May 03, 2006, at 10:15 UTC, Emile Schwarz wrote:


I had two times the same Dim line, the first in the If part, and the second in the Else part.


So?  There's nothing wrong with that.  The first variable ceases to exist at 
the end of the if part, and so that name is free to be used again in the else 
part.  This is most definitely a feature; it lets you write each block of code 
without such tight coupling to neighboring blocks of code.
You are correct.

But:

1. I do not do it on purpose ;)
2. I use the same variables;
3. I remove the duplicate lines and put the original at the top of the event/function/method/whatever and it was good;
4. It was not mandatory to do that.

All of that said, I was surprised - to have two times the same lines - and was asking if this is a feature (or a "collateral damage").


Thank you for your kind answer,

Emile


BTW: If you place a Dim line (or two or more) in the If block _AND_ that very same Dim line exists in the beginning of the code _OR_ outside of the If block, REALbasic flag the error and displays the first line as an error:

"Error: This name is already in use."


Quite right.  In this case, the first variable has not gone out of scope at the 
point at which you're trying to use the same name again.

Yes, I was expecting that.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to