Calculating, Calling & Printing return values ????

D

David

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 week"

or

"<font color=dark orange>There are " & CALC & " units scheduled for
this week"
..

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
week"
else
return "<font color=dark orange>There are " & CALC & " units scheduled
for this week"
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 week

<record 1>
<record 2>
<record 3>
<record 4>

< some text here > scheduled for 28/02/06
There are 1163 units scheduled for this week

<record 1>
<record 2>
<record 3>
<record 4>

< some text here > scheduled for 05/03/06
There are NO units scheduled for this week

< some text here > scheduled for 18/04/06
There are 532 units scheduled for this week

<record 1>
<record 2>
<record 3>
<record 4>

-------------------------------------------------------


Appreciate all your help
Thank You
David Gordon
 
A

Anthony Jones

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top