Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Redefined variable

Reply
Thread Tools

Redefined variable

 
 
Serge Myrand
Guest
Posts: n/a
 
      07-18-2004
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



 
Reply With Quote
 
 
 
 
Jeff Cochran
Guest
Posts: n/a
 
      07-18-2004
On Sun, 18 Jul 2004 10:19:51 -0300, Serge Myrand
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Bob Lehmann
Guest
Posts: n/a
 
      07-18-2004
Why do you need to load it twice?

Bob Lehmann

"Serge Myrand" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Rob Collyer
Guest
Posts: n/a
 
      07-18-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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Serge Myrand
Guest
Posts: n/a
 
      07-18-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
> <(E-Mail Removed)> 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


 
Reply With Quote
 
Serge Myrand
Guest
Posts: n/a
 
      07-18-2004
Hi,
see my answer to Jeff above

serge

Bob Lehmann wrote:

> Why do you need to load it twice?
>
> Bob Lehmann
>
> "Serge Myrand" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >
> >


 
Reply With Quote
 
Serge Myrand
Guest
Posts: n/a
 
      07-18-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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >
> >


 
Reply With Quote
 
Bob Lehmann
Guest
Posts: n/a
 
      07-18-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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> see my answer to Jeff above
>
> serge
>
> Bob Lehmann wrote:
>
> > Why do you need to load it twice?
> >
> > Bob Lehmann
> >
> > "Serge Myrand" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >
> > >

>



 
Reply With Quote
 
Jeff Cochran
Guest
Posts: n/a
 
      07-18-2004
On Sun, 18 Jul 2004 14:19:29 -0300, Serge Myrand
<(E-Mail Removed)> 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
>> <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
_POSIX_C_SOURCE redefined (Problems with Python.h?) irfanhab C Programming 1 08-23-2006 08:00 AM
Trying to pass values of variables from a redefined function into another function deanfamily C++ 4 10-23-2005 11:36 PM
Array.sort when it's items are String inheritors with redefined <=> works like if not redefined MiG Ruby 8 10-19-2005 03:48 PM
template-class-id redefined problem saksenaabhishek@rediffmail.com C++ 1 04-01-2005 03:00 PM
function redefined problem Wei Li C Programming 11 08-27-2004 09:30 PM



Advertisments