Click to See Complete Forum and Search --> : Execute causing Redefined error


tomhartland
03-29-2004, 04:50 AM
Greetings :-)

I've been struggling with this for while without success. If anybody has an ideas...?
The problem occured in a big site, but this tiny bit of code will replicate the problem:

"Constants" file "tom.inc"...Public Const TOM_TEST_1 = 123
"tom.asp"...<script language="vbscript" src="tom.inc"
runat="server"></script>
<%
Dim strTom
Execute "strTom = TOM_TEST_1"
%>
This results in...
Name redefined: 'TOM_TEST_1'
/test/tom.inc, line 1

Am I missing something to do with the execution order of the "tom.inc" file in comparison with the rest of the code?

Any help would be greatly appreciated.
Tom :-)

buntine
03-29-2004, 05:36 AM
Why not include the file from the server?

<!-- #include file="tom.inc" -->


Also, i dont believe the Public keyword is required here.

Regards.

tomhartland
03-29-2004, 05:47 AM
Thanks for your reply Buntine :-)

Let me tell you a story of the my checkered ASP past - nah, I'll just give a quick explaination of why I'm thick...

I used to use the "constant" file in my global.asa, and as I could only use the <script> method to include the file, I couldn't have <% %> surrounding the constants.
This was why I had to use the <script> method in all the other necessary ASP pages.

Due to one thing and another I have stopped using those constants in global.asa, but had completely forgotten about the fact.

So in short, #include is exactly what I needed - cheers mate :-)
Tom

buntine
03-29-2004, 05:53 AM
No worries.

I often forget things like this -- especially if i am developing in a different language for a period of time.

I once got stuck on a select - case conditional statement because i kept using the C, Java switch keyword! :p

Regards.