PDA

View Full Version : include file Error



nhovehn
06-27-2005, 05:44 PM
Hi,

I design a website by asp and in two languages (English & Vietnamese).
I have lang directory and contain 2 files: vn.asp and en.asp
Content of 2 files:
File vn.asp:


CONST MSG_TITLE = "Word in Vietnamese here"

and File en.asp:


CONST MSG_TITLE = "Word in English here"


I have index.asp file in root directory, in this file have some contents:


<%
lang=Request.QueryString("lang")
Select Case lang
Case "vn"
%>
<!--
#include file="lang/vn.asp"
-->
<%
Case "en"
%>
<!--
#include file="lang/en.asp"
-->
<%
End Select
%>
...
<A Href="index.asp?lang=vn">Vietnamese</A>
<A Href="index.asp?lang=en">English</A>
...


But have problem when I access this index.asp:


Error Type:
Microsoft VBScript compilation (0x800A0411)
Name redefined
/lang/en.lang.asp, line 3, column 6
CONST MSG_TITLE = "Word in Vietnamese here"


Someone help me plz!
Thks

Spudhead
06-27-2005, 06:34 PM
You might want to read this (http://www.4guysfromrolla.com/webtech/022504-1.shtml) article regarding conditional includes in ASP. :thumbsup:

Zeeshan Arshad
06-27-2005, 07:11 PM
Hi Hove,

the problem is CONST MSG_TITLE

you have included two files within same page and each file defines CONSTANT.

just use this scenario:

<!--
#include file="lang/variables.asp"
-->
<%
lang=Request.QueryString("lang")
Select Case lang
Case "vn"
%>
<!--
#include file="lang/vn.asp"
-->
<%
Case "en"
%>
<!--
#include file="lang/en.asp"
-->
<%
End Select
%>

and use MSG_TITLE = "xxxx" in each file and define CONST MSG_TITLE
inside variables.asp file.

otherwise you can simply remove CONST from both language files without define and it would work.

Thanks.