[Zope] RE: [Zope-dev] variables in zope (beginner question)

Joel Burton joel@joelburton.com
Mon, 11 Mar 2002 21:46:31 -0500 (EST)


On Mon, 11 Mar 2002 sean.upton@uniontrib.com wrote:

> Hello,
>
> I the code below I want to be declare a variable 'tot_net_amt' and add
> 'net_amt' to it for each record returned.  How can I: 1) declare the
> variable  2) add to it within the loop.
>
> Thanks.  Is it in the Zope book?  I'll read some more tonight.
>
> Thanks for your help.
>
> Mike
>
>
>
> <dtml-var standard_html_header>
> <h3>Current Month</h3>
>
> <!-- declare tot_net_amt  int := 0;  --->
>
> <table border="1" cellspacing="0">
> <tr>
>     <th><font size="1">Sales Order No.</font></th>
>     <th><font size="1">Net Amt.</font></th>
> </tr>
> <dtml-in sql_curr_month_decom>
>   <tr>
>       <!--- net_tot_amt := net_tot_amt + <dtml-var net_amt>  --->
>
>       <td align="center"><font size="1"><dtml-var sales_ord_no></font></td>
>       <td align="center"><font size="1"><dtml-var net_amt></font></td>
>   </tr>
> </dtml-in>
> </table>
> <dtml-var standard_html_footer>

<dtml-call "REQUEST.set('total',0)">

<dtml-in someLoop>
  <dtml-call "REQUEST.set('total', REQUEST.total + net_amt)">
</dtml-in>

The Zope Book will teach you about the use of REQUEST.set()

-- 

Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: wjoelburton
Independent Knowledge Management Consultant