Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Name Redefined

Reply
Thread Tools

Name Redefined

 
 
James
Guest
Posts: n/a
 
      04-12-2005
Should be a simple question...not sure why this ISN'T having a problem:

For x = 1 to 5
Dim y
Next

Shouldn't that fire a "Name Redefined" error the way this does:

For x = 1 to 5
Dim y
Next

Dim y


 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      04-12-2005
The parser is pretty stupid. In the second case, it reads through the code
(without executing the loop) and sees two identical Dim statements. It has
nothing to do with how many times the statement is actually executed; only
with how many times it appears.

--
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.

"James" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Should be a simple question...not sure why this ISN'T having a problem:
>
> For x = 1 to 5
> Dim y
> Next
>
> Shouldn't that fire a "Name Redefined" error the way this does:
>
> For x = 1 to 5
> Dim y
> Next
>
> Dim y
>
>



 
Reply With Quote
 
 
 
 
James
Guest
Posts: n/a
 
      04-12-2005
Makes sense...just wanted to make sure I wasn't missing anything. Thanks.

"Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
news:%23WkG$(E-Mail Removed)...
> The parser is pretty stupid. In the second case, it reads through the

code
> (without executing the loop) and sees two identical Dim statements. It

has
> nothing to do with how many times the statement is actually executed; only
> with how many times it appears.
>
> --
> This is my signature. It is a general reminder.
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
> "James" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Should be a simple question...not sure why this ISN'T having a problem:
> >
> > For x = 1 to 5
> > Dim y
> > Next
> >
> > Shouldn't that fire a "Name Redefined" error the way this does:
> >
> > For x = 1 to 5
> > Dim y
> > Next
> >
> > Dim y
> >
> >

>
>



 
Reply With Quote
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      04-12-2005
Now that you have your answer, may I ask if you are really planning on
dimming something in a loop like this? Or were you just playing around
trying to get an error?

Ray at work

"James" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Should be a simple question...not sure why this ISN'T having a problem:
>
> For x = 1 to 5
> Dim y
> Next
>
> Shouldn't that fire a "Name Redefined" error the way this does:
>
> For x = 1 to 5
> Dim y
> Next
>
> Dim y
>
>



 
Reply With Quote
 
James
Guest
Posts: n/a
 
      04-12-2005
LOL, no...I don't intend to design something like this. Long story short,
I have an ENORMOUS page built by someone else in our company that's long
since departed. From a bare glance at the page, I knew where I needed to
put my add on, but I wasn't sure if I was inside any kind of a loop. The
code is horribly indented/commented. Curiousity sparked my example. I
ended up having to document/format the page anyway. I wasn't intending to
proceed without knowing exactly what was going on anyway. Just curiousity
=).

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:(E-Mail Removed)...
> Now that you have your answer, may I ask if you are really planning on
> dimming something in a loop like this? Or were you just playing around
> trying to get an error?
>
> Ray at work
>
> "James" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Should be a simple question...not sure why this ISN'T having a problem:
> >
> > For x = 1 to 5
> > Dim y
> > Next
> >
> > Shouldn't that fire a "Name Redefined" error the way this does:
> >
> > For x = 1 to 5
> > Dim y
> > Next
> >
> > Dim y
> >
> >

>
>



 
Reply With Quote
 
Stefan Berglund
Guest
Posts: n/a
 
      04-13-2005
On Tue, 12 Apr 2005 13:06:24 -0400, "Ray Costanzo [MVP]" <my first name
at lane 34 dot commercial> wrote:
in <(E-Mail Removed)>

>Now that you have your answer, may I ask if you are really planning on
>dimming something in a loop like this? Or were you just playing around
>trying to get an error?
>
>Ray at work


It makes no matter where your Dims appear as long as they precede any
reference to the variable. I put all my Dims right where the variable
is used the first time which makes for more readable code IMHO.


---
Stefan Berglund
 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      04-13-2005
IIRC it doesn't matter where you put your dims as long as they are in the
same scope as the variable reference. Try this.

<%@ Language=VBScript %>
<%

data = "here I am"

dim data

Response.Write data
%>

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Stefan Berglund" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Tue, 12 Apr 2005 13:06:24 -0400, "Ray Costanzo [MVP]" <my first name
> at lane 34 dot commercial> wrote:
> in <(E-Mail Removed)>
>
>>Now that you have your answer, may I ask if you are really planning on
>>dimming something in a loop like this? Or were you just playing around
>>trying to get an error?
>>
>>Ray at work

>
> It makes no matter where your Dims appear as long as they precede any
> reference to the variable. I put all my Dims right where the variable
> is used the first time which makes for more readable code IMHO.
>
>
> ---
> Stefan Berglund



 
Reply With Quote
 
Stefan Berglund
Guest
Posts: n/a
 
      04-14-2005
On Wed, 13 Apr 2005 09:33:22 -0700, "Mark Schupp" <(E-Mail Removed)>
wrote:
in <(E-Mail Removed)>

>IIRC it doesn't matter where you put your dims as long as they are in the
>same scope as the variable reference. Try this.
>
><%@ Language=VBScript %>
><%
>
>data = "here I am"
>
>dim data
>
>Response.Write data
>%>


Interesting. VBScript is more forgiving than VB6.


---
Stefan Berglund
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
_POSIX_C_SOURCE redefined (Problems with Python.h?) irfanhab C Programming 1 08-23-2006 08:00 AM
Array.sort when it's items are String inheritors with redefined <=> works like if not redefined MiG Ruby 8 10-19-2005 03:48 PM
template-class-id redefined problem saksenaabhishek@rediffmail.com C++ 1 04-01-2005 03:00 PM
function redefined problem Wei Li C Programming 11 08-27-2004 09:30 PM
dim Name redefined error DaveF ASP General 8 04-14-2004 04:53 PM



Advertisments