|
 |
asp_databases thread: include file
Message #1 by "jong wan chin" <jongwc@s...> on Tue, 24 Jul 2001 09:38:51
|
|
dear all,
i have a .asp file which contain calculation function (let's call the file
calculate.asp). i wish to call the file from other .asp page (let say
page A).
in order to execute the calculate, i include the calculate .asp in page
A.
<!--#include file ="calculate.asp"-->
my problem now is, how can i send the data from page A to calculate.asp??
the data is needed for the calculation.
i hope some one can give me some advice. i have no idea how should i do
this.
thanks.
regards,
jong
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 24 Jul 2001 19:04:56 +1000
|
|
This is the way that I'd do it. Wrap the functionality in the include file
into a routine (eg a function). Call the function from the main part of your
code:
--- calculator.asp ---
<%
Function fncAddTwoNumbers ( _
ByVal intFirstNumber, _
ByVal intSecondNumber _
)
fncAddTwoNumbers = intFirstNumber + intSecondNumber
End Function
%>
--- mainpage.asp ---
<!-- #include virtual="/inc/calculator.asp" -->
<%
int1 = 5
int2 = 6
intTotal = fncAddTwoNumbers(int1, int2)
Response.Write(intTotal)
%>
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "jong wan chin" <jongwc@s...>
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, July 24, 2001 9:38 AM
Subject: [asp_databases] include file
: dear all,
: i have a .asp file which contain calculation function (let's call the file
: calculate.asp). i wish to call the file from other .asp page (let say
: page A).
: in order to execute the calculate, i include the calculate .asp in page
: A.
:
: <!--#include file ="calculate.asp"-->
:
: my problem now is, how can i send the data from page A to calculate.asp??
: the data is needed for the calculation.
:
: i hope some one can give me some advice. i have no idea how should i do
: this.
:
: thanks.
:
: regards,
: jong
Message #3 by "raghu bejgum" <raghu_hale@h...> on Tue, 24 Jul 2001 17:40:53 +0530
|
|
Hi, The variables defined in an asp page are automatically accessible in the
file included in it.. provided the variables should be defined ahead of the
place where u write the include file syntax. Try like this and lemme know if
u have more problems...
Raghavendra.B
S/w Engg
Globarena Group
>From: "jong wan chin" <jongwc@s...>
>Reply-To: "ASP Databases" <asp_databases@p...>
>To: "ASP Databases" <asp_databases@p...>
>Subject: [asp_databases] include file
>Date: Tue, 24 Jul 2001 09:38:51
>
>dear all,
>i have a .asp file which contain calculation function (let's call the file
>calculate.asp). i wish to call the file from other .asp page (let say
>page A).
>in order to execute the calculate, i include the calculate .asp in page
>A.
>
><!--#include file ="calculate.asp"-->
>
>my problem now is, how can i send the data from page A to calculate.asp??
>the data is needed for the calculation.
>
>i hope some one can give me some advice. i have no idea how should i do
>this.
>
>thanks.
>
>regards,
>jong
>
Message #4 by iashraf@a... on Tue, 24 Jul 2001 17:50:45 +0500
|
|
Hi jong
your code in calculate.asp should be function based. then in which file
you'll include this file then you can use functions built in this file and
pass the data as parameter which you want to calculate.
Try this.........
Imran Ashraf
Acrologix (pvt) Ltd.
106/3 Saint Johns Park,
Lahore, Pakistan.
Tel: 92-42-666-4301~6
Fax: 92-42-666-4307
Mob: 0300 - 8662678
Email: iashraf@a...
Message #5 by "D a v i d" <registerukh@h...> on Tue, 24 Jul 2001 11:04:20 -0500
|
|
Just pretend that calculate.asp doesnt exist separately and infact it's code
is directly copied and pasted in your pageA. Now proceed from here. Is this
is what you were looking for?
>From: "jong wan chin" <jongwc@s...>
>Reply-To: "ASP Databases" <asp_databases@p...>
>To: "ASP Databases" <asp_databases@p...>
>Subject: [asp_databases] include file
>Date: Tue, 24 Jul 2001 09:38:51
>
>dear all,
>i have a .asp file which contain calculation function (let's call the file
>calculate.asp). i wish to call the file from other .asp page (let say
>page A).
>in order to execute the calculate, i include the calculate .asp in page
>A.
>
><!--#include file ="calculate.asp"-->
>
>my problem now is, how can i send the data from page A to calculate.asp??
>the data is needed for the calculation.
>
>i hope some one can give me some advice. i have no idea how should i do
>this.
>
>thanks.
>
>regards,
>jong
>---
Message #6 by Steve Carter <Steve.Carter@t...> on Tue, 24 Jul 2001 17:17:56 +0100
|
|
Yes, something like the following will work:
--------8<----- calc.asp -----8<---------
<%
function addStuff(a,b,c)
addStuff =3D a + b + c
end function
sub printACoolDiv()
response.write("<DIV style=3D""position: absolute; top: 10px; " & _
"left: 20px; color: red; filter:
alpha(opacity=3D75)"">HELLO</DIV>")
end sub
%>
--------8<--- END calc.asp ---8<---------
--------8<----- main.asp -----8<---------
<!-- #include file=3D"calc.asp" -->
<HTML><HEAD>
<TITLE>The total is <%
response.write addStuff(7,10,3)
%></TITLE>
</HEAD>
<BODY>
<%
printACoolDiv
%>
</BODY>
</HTML>
--------8<--- END main.asp ---8<---------
So the answer is to make sure you put functions and subs in the
included
files, then
you can access them in this way.
> -----Original Message-----
> From: D a v i d [mailto:registerukh@h...]
> Sent: 24 July 2001 17:04
> To: ASP Databases
> Subject: [asp_databases] Re: include file
>
>
> Just pretend that calculate.asp doesnt exist separately and
> infact it's code
> is directly copied and pasted in your pageA. Now proceed from
> here. Is this
> is what you were looking for?
>
>
>
> >From: "jong wan chin" <jongwc@s...>
> >Reply-To: "ASP Databases" <asp_databases@p...>
> >To: "ASP Databases" <asp_databases@p...>
> >Subject: [asp_databases] include file
> >Date: Tue, 24 Jul 2001 09:38:51
> >
> >dear all,
> >i have a .asp file which contain calculation function (let's
> call the file
> >calculate.asp). i wish to call the file from other .asp
> page (let say
> >page A).
> >in order to execute the calculate, i include the calculate
> .asp in page
> >A.
> >
> ><!--#include file =3D"calculate.asp"-->
> >
> >my problem now is, how can i send the data from page A to
> calculate.asp??
> >the data is needed for the calculation.
> >
> >i hope some one can give me some advice. i have no idea how
> should i do
> >this.
> >
> >thanks.
> >
> >regards,
> >jong
> >
Message #7 by "jong wan chin" <jongwc@s...> on Wed, 25 Jul 2001 14:42:49 +0800
|
|
hi all,
i try the method --> store function in calculate.asp....
But i get this error:
Microsoft VBScript compilation error '800a03ea'
Syntax error
/calculate.asp, line 2
FUNCTION totalTarget(compLev, prio)
^
here is the code that i use.
========= calculate.asp===========
<%
FUNCTION totalTarget(compLev, prio)
totalTarget=compLev * prio
End FUNCTION
FUNCTION totalActual(achLev, prio)
totalActual=achLev(i) * prio
End FUNCTION
FUNCTION countPercent(actual, target)
countPercent = actual/target * 100
End FUNCTION
%>
===============================
here is the code i use to call the function:
============ main.asp==============
<%
For i=1 to lngTotal 'I have an
array of data in "skillID", "comp_level" and "LEVEL"
skill=Request.Form("skillID")(i)
comp=Request.Form("comp_level")(i)
lev=request.form("LEVEL")(i)
Set rst2=cnn.execute("SELECT * FROM SKILL_COMPETENCY WHERE
JOB_ID='"&jobID&"' AND SKILL_ID='"&skill&"'")
prio=rst2("PRIORITY")
%>
<!--#include file ="calculate.asp"-->
<%
target=target + totalTarget(comp,prio)
actual=actual + totalActual(lev,prio)
Next
percent=countPercent(target, actual)
%>
========================================
please help me to solve this problem.
thanks.
regards,
jong
|
|
 |