Calculating, Calling & Printing return values ????

Discussion in 'ASP General' started by David, Feb 13, 2006.

  1. David

    David Guest

    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
     
    David, Feb 13, 2006
    #1
    1. Advertising

  2. >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.
     
    Anthony Jones, Feb 18, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon B
    Replies:
    7
    Views:
    7,516
    =?Utf-8?B?SmFzb25DaG9p?=
    Jan 30, 2006
  2. JustSomeGuy
    Replies:
    13
    Views:
    514
    msalters
    Dec 9, 2004
  3. Greenhorn
    Replies:
    15
    Views:
    833
    Keith Thompson
    Mar 6, 2005
  4. Chris Rebert
    Replies:
    1
    Views:
    685
    Bobby
    May 28, 2009
  5. Shekhar
    Replies:
    0
    Views:
    188
    Shekhar
    Jul 16, 2004
Loading...

Share This Page