469,343 Members | 5,279 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Redefined variable

Hi everybody,

In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test

with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.

' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge

Jul 19 '05 #1
8 2252
On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
<in**@softdelirium.qc.ca> wrote:
In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test
Why would you need to include a file twice? If it has different
values for the variables, name them differently and include them once.
with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.
No.
' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if


Hmm... Using a variable before defining it, why would that cause an
error?

You can REDIM if needed, but rethink your code and do it correctly the
first time.

Jeff
Jul 19 '05 #2
Why do you need to load it twice?

Bob Lehmann

"Serge Myrand" <in**@softdelirium.qc.ca> wrote in message
news:40***************@softdelirium.qc.ca...
Hi everybody,

In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test

with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.

' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge

Jul 19 '05 #3
One way, would be to lose 'option explicit' and all your variable
declarations (dim statements)

Although I have to say, including a file more than once is generally a sign
of bad coding practice....

I'm sure there will be a much much better way of achieving what you want
without resorting to including the same file multiple times.
--
Rob Collyer - www.webforumz.com
Web design and development forums for Free help, advice,
tips, and website critique by professional designers and developers.

"Serge Myrand" <in**@softdelirium.qc.ca> wrote in message
news:40***************@softdelirium.qc.ca...
Hi everybody,

In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test

with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.

' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge

Jul 19 '05 #4
Hi,

Because this is a menu bar and there is an option taht allow the user to put
it at the bottom and at the top of the page.

serge

Jeff Cochran wrote:
On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
<in**@softdelirium.qc.ca> wrote:
In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test


Why would you need to include a file twice? If it has different
values for the variables, name them differently and include them once.
with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.


No.
' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if


Hmm... Using a variable before defining it, why would that cause an
error?

You can REDIM if needed, but rethink your code and do it correctly the
first time.

Jeff


Jul 19 '05 #5
Hi,
see my answer to Jeff above

serge

Bob Lehmann wrote:
Why do you need to load it twice?

Bob Lehmann

"Serge Myrand" <in**@softdelirium.qc.ca> wrote in message
news:40***************@softdelirium.qc.ca...
Hi everybody,

In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test

with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.

' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge


Jul 19 '05 #6
Hi,

see my answer to Jeff above

thank's
serge
Rob Collyer wrote:
One way, would be to lose 'option explicit' and all your variable
declarations (dim statements)

Although I have to say, including a file more than once is generally a sign
of bad coding practice....

I'm sure there will be a much much better way of achieving what you want
without resorting to including the same file multiple times.
--
Rob Collyer - www.webforumz.com
Web design and development forums for Free help, advice,
tips, and website critique by professional designers and developers.

"Serge Myrand" <in**@softdelirium.qc.ca> wrote in message
news:40***************@softdelirium.qc.ca...
Hi everybody,

In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test

with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.

' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge


Jul 19 '05 #7
OK. So why don't you put it in a function and call the function to output
the menu?

Function TheMenu
TheMenu = "Some HTML for the menu"
End Function

If MenuPreference ="top" Then
Response.Write TheMenu
End If

Bob Lehmann

"Serge Myrand" <in**@softdelirium.qc.ca> wrote in message
news:40***************@softdelirium.qc.ca...
Hi,
see my answer to Jeff above

serge

Bob Lehmann wrote:
Why do you need to load it twice?

Bob Lehmann

"Serge Myrand" <in**@softdelirium.qc.ca> wrote in message
news:40***************@softdelirium.qc.ca...
Hi everybody,

In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test
with VarType before to define the variable (dim) with no success. Is it faisable with VBScript to define a variable (dim) under condition.

' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge

Jul 19 '05 #8
On Sun, 18 Jul 2004 14:19:29 -0300, Serge Myrand
<in**@softdelirium.qc.ca> wrote:
Because this is a menu bar and there is an option taht allow the user to put
it at the bottom and at the top of the page.
So? Do this:

[Menubar.asp]

<%
Sub Menubar
Dim Menubar1, Menubar2
...Menubar code...
End Sub
%>

[Page.asp]

<!--#include virtual="menubar.asp"-->

<%
Menubar
Response.Write "Page text and stuff..."
Menubar
%>

Learn to use subs and functions.

Jeff

serge

Jeff Cochran wrote:
On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
<in**@softdelirium.qc.ca> wrote:
>In an ASP page, I need to load twice an include file that contains
>variables. So I get an error message "variable redefine" I tried to test


Why would you need to include a file twice? If it has different
values for the variables, name them differently and include them once.
>with VarType before to define the variable (dim) with no success. Is it
>faisable with VBScript to define a variable (dim) under condition.


No.
>' this code gives an error
>if VarType("MyVar") = vbNull then
> dim MyVar
>end if


Hmm... Using a variable before defining it, why would that cause an
error?

You can REDIM if needed, but rethink your code and do it correctly the
first time.

Jeff


Jul 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Marc Schellens | last post: by
7 posts views Thread by James | last post: by
1 post views Thread by saksenaabhishek | last post: by
reply views Thread by Myron Turner | last post: by
134 posts views Thread by James A. Donald | last post: by
pbmods
1 post views Thread by pbmods | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.