Home > Archive > ASP > February 2006 > Calculating, Calling & Printing return values ????
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Calculating, Calling & Printing return values ????
|
|
|
| Hi,
I have a problem with returning a value from an external function.....
My asp page is basically a list taken from a database.
A date record is written from the DB, then all the recordslinked to
that date are listed, then the next date, then the next series of
records, i.e.
< some text here > scheduled for 21/02/06
<record 1>
<record 2>
<record 3>
<record 4>
< some text here > scheduled for 28/02/06
<record 1>
<record 2>
<record 3>
<record 4>
----------------------------------------------------
Within the loop for each record within in each date, a calculation is
done as follows:
CALC = CALC + (RS("ProdCount") * RS("ShipQty"))
At the end of each record cycle within a date range, I want to print
the following, pending what the value of CALC is.
"<font color=dark orange>There are NO units scheduled for this w "
or
"<font color=dark orange>There are " & CALC & " units scheduled for
this w "
..
I think I need to call a function to do this because I whish to print
the result, next to each date header, which preceeds the actual
records, ...... & docalc(CALC) & .......
I created a function, docalc(CALC) in an include file, and assumed that
where I wish to print the result, I just call my function as follows
(which does not work yet ?)
Where & how should I place/create the variable 'CALC' and the function
below ?
<%
function docalc(CALC)
if isnull(CALC) or CALC = 0 then
return "<font color=dark orange>There are NO units scheduled for this
w "
else
return "<font color=dark orange>There are " & CALC & " units scheduled
for this w "
end if
end function
%>
What am I doing wrong. The end result should look something like this :
< some text here > scheduled for 21/02/06
There are 534 units scheduled for this w
<record 1>
<record 2>
<record 3>
<record 4>
< some text here > scheduled for 28/02/06
There are 1163 units scheduled for this w
<record 1>
<record 2>
<record 3>
<record 4>
< some text here > scheduled for 05/03/06
There are NO units scheduled for this w
< some text here > scheduled for 18/04/06
There are 532 units scheduled for this w
<record 1>
<record 2>
<record 3>
<record 4>
-------------------------------------------------------
Appreciate all your help
Thank You
David Gordon
| |
| Anthony Jones 2006-02-18, 6:55 pm |
| >I think I need to call a function to do this because I whish to print
>the result, next to each date header, which preceeds the actual
>records, ...... & docalc(CALC) & .......
Instead of sending you html output to the Response for a set of records
append them to a string variable instead (this does mean you need to
generate all the output for records in inline script).
Once you have got to the end of a set of records your CALC value will be at
the correct value. You can now output the date and 'units scheduled'
preamble then write the html in the string variable to the response.
Clear the string variable and Calc value to start again for the next date.
Anthony.
|
|
|
|
|