473,248 Members | 1,169 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,248 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 2319
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
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.