Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:16 PM
Serge Myrand
Guest
 
Posts: n/a
Default 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



  #2  
Old July 19th, 2005, 02:16 PM
Jeff Cochran
Guest
 
Posts: n/a
Default Re: Redefined variable

On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
<info@softdelirium.qc.ca> wrote:
[color=blue]
>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[/color]

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

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

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
  #3  
Old July 19th, 2005, 02:16 PM
Bob Lehmann
Guest
 
Posts: n/a
Default Re: Redefined variable

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...[color=blue]
> 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
>
>
>[/color]


  #4  
Old July 19th, 2005, 02:16 PM
Rob Collyer
Guest
 
Posts: n/a
Default Re: Redefined variable

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...[color=blue]
> 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
>
>
>[/color]


  #5  
Old July 19th, 2005, 02:16 PM
Serge Myrand
Guest
 
Posts: n/a
Default Re: Redefined variable

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:
[color=blue]
> On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
> <info@softdelirium.qc.ca> wrote:
>[color=green]
> >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[/color]
>
> Why would you need to include a file twice? If it has different
> values for the variables, name them differently and include them once.
>[color=green]
> >with VarType before to define the variable (dim) with no success. Is it
> >faisable with VBScript to define a variable (dim) under condition.[/color]
>
> No.
>[color=green]
> >' this code gives an error
> >if VarType("MyVar") = vbNull then
> > dim MyVar
> >end if[/color]
>
> 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[/color]

  #6  
Old July 19th, 2005, 02:16 PM
Serge Myrand
Guest
 
Posts: n/a
Default Re: Redefined variable

Hi,
see my answer to Jeff above

serge

Bob Lehmann wrote:
[color=blue]
> 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...[color=green]
> > 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
> >
> >
> >[/color][/color]

  #7  
Old July 19th, 2005, 02:16 PM
Serge Myrand
Guest
 
Posts: n/a
Default Re: Redefined variable

Hi,

see my answer to Jeff above

thank's
serge


Rob Collyer wrote:
[color=blue]
> 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...[color=green]
> > 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
> >
> >
> >[/color][/color]

  #8  
Old July 19th, 2005, 02:16 PM
Bob Lehmann
Guest
 
Posts: n/a
Default Re: Redefined variable

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...[color=blue]
> Hi,
> see my answer to Jeff above
>
> serge
>
> Bob Lehmann wrote:
>[color=green]
> > 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...[color=darkred]
> > > 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[/color][/color][/color]
test[color=blue][color=green][color=darkred]
> > >
> > > with VarType before to define the variable (dim) with no success. Is[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > 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
> > >
> > >
> > >[/color][/color]
>[/color]


  #9  
Old July 19th, 2005, 02:16 PM
Jeff Cochran
Guest
 
Posts: n/a
Default Re: Redefined variable

On Sun, 18 Jul 2004 14:19:29 -0300, Serge Myrand
<info@softdelirium.qc.ca> wrote:
[color=blue]
>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.[/color]

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

[color=blue]
>serge
>
>Jeff Cochran wrote:
>[color=green]
>> On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
>> <info@softdelirium.qc.ca> wrote:
>>[color=darkred]
>> >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[/color]
>>
>> Why would you need to include a file twice? If it has different
>> values for the variables, name them differently and include them once.
>>[color=darkred]
>> >with VarType before to define the variable (dim) with no success. Is it
>> >faisable with VBScript to define a variable (dim) under condition.[/color]
>>
>> No.
>>[color=darkred]
>> >' this code gives an error
>> >if VarType("MyVar") = vbNull then
>> > dim MyVar
>> >end if[/color]
>>
>> 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[/color][/color]

 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles