473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2323
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marc Schellens | last post by:
Including Python.h I got the following warining warning: "_POSIX_C_SOURCE" redefined in Python.h: #define _POSIX_C_SOURCE 200112L in features.h (included from string):
7
by: James | last post by:
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
1
by: saksenaabhishek | last post by:
Hi Guys, I have some problem in compiling the following code, specially with MSVC++.Net2003 (Code works fine with GCC compiler) ========================================= template< typename...
0
by: Myron Turner | last post by:
I'm using a child handler which I've used elsewhere on various systems, but currently I am getting this message: POSIX::WNOHANG redefined my handler is as follows: sub childhandler { ...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
4
by: deanfamily | last post by:
Here's the problem: I have a function that references another one in this manner: class circleType: public pointType so, pointType is redefined by circleType, thereby giving circleType access to...
1
by: irfanhab | last post by:
Hey guys! I am having some serious problems integrating Python and C, and it's strange. Putting it simple, Just as I include Python.h in my C programe (without any further python interfacing...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
1
by: colin | last post by:
Hi, I have this code wich fills in data fields from a file, recursivley down through any structures/classes the difficulty is when I come acros a field wich is a structure, wich can not be read...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.