Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem calling function from include asp file

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have a function on my include asp that declares and assign values to some variables.
When I call this function from another asp page, the values are not returned to the calling asp page.

Any help will be greatly appreciated.
 
Plenty of psychos here, but few psychics.

No code = no answers.

Lee
 
This is an simple overview of my script:

Here is the sample of the calling page

<%@ Language=VBScript %>
<% Response.Buffer=False %>
<%'Option Explicit

Response.Expires = -5000
Server.ScriptTimeout = 10800

%>

<!-- #INCLUDE FILE="include_page.asp" -->


<html>

<head>
<title></title>

</head>

<body>

<%


DeclareVar()


Response.write (Location) 'This was not returned by the procedure (pages are in same directory)

if Location = "CALIFORNIA" then

aryStores = array("GAP", "OLD_NAVY", "BANANA_REPUBLIC")

else

aryStores = array("GAP", "BANANA_REPUBLIC")

end if



for each Stores in aryStore

'......Do something

next

%>

</body>

</html>


'*****************************************************************************************************************************



Here is a sample of my include asp page (include_page.asp)


<SCRIPT LANGUAGE=VBScript RUNAT=Server>


sub DeclareVar()

Dim Location
Dim Stores, aryStores
Dim CurrentMonth

Location = "CALIFORNIA"

end sub





 
The scope of the variable named Location is limitted to the method DeclareVar.
Try declaring the variable outside the Subroutine.




Another way is to use a function:[tt]
x = DeclareVar()

function DeclareVar()
DeclareVar = "CALIFORNIA"
end function
[/tt]
 
In the procedure DeclareVar, I have a handful of variables that I need to declare and assign. I need to create this function so that it can be used by all my asp pages, without me declaring and assigning variables in the individual pages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top