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

Re: Redefined variable by jeff

jeff
Sun Jul 18 10:02:19 CDT 2004

On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
<info@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

Re: Redefined variable by Bob

Bob
Sun Jul 18 10:02:30 CDT 2004

Why do you need to load it twice?

Bob Lehmann

"Serge Myrand" <info@softdelirium.qc.ca> wrote in message
news:40FA78F7.B87E06B3@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
>
>
>



Re: Redefined variable by Rob

Rob
Sun Jul 18 11:01:48 CDT 2004

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" <info@softdelirium.qc.ca> wrote in message
news:40FA78F7.B87E06B3@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
>
>
>



Re: Redefined variable by Serge

Serge
Sun Jul 18 12:19:29 CDT 2004

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
> <info@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


Re: Redefined variable by Serge

Serge
Sun Jul 18 12:21:30 CDT 2004

Hi,
see my answer to Jeff above

serge

Bob Lehmann wrote:

> Why do you need to load it twice?
>
> Bob Lehmann
>
> "Serge Myrand" <info@softdelirium.qc.ca> wrote in message
> news:40FA78F7.B87E06B3@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
> >
> >
> >


Re: Redefined variable by Serge

Serge
Sun Jul 18 12:21:58 CDT 2004

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" <info@softdelirium.qc.ca> wrote in message
> news:40FA78F7.B87E06B3@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
> >
> >
> >


Re: Redefined variable by Bob

Bob
Sun Jul 18 15:41:56 CDT 2004

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" <info@softdelirium.qc.ca> wrote in message
news:40FAB199.ACA8146C@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" <info@softdelirium.qc.ca> wrote in message
> > news:40FA78F7.B87E06B3@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
> > >
> > >
> > >
>



Re: Redefined variable by jeff

jeff
Sun Jul 18 18:41:10 CDT 2004

On Sun, 18 Jul 2004 14:19:29 -0300, Serge Myrand
<info@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
>> <info@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