On 11/26/01 7:26 AM, "Dave Everson" <[EMAIL PROTECTED]> wrote:

> Can someone please help me understand how to produce running totals using
> Velocity.
> 
> Thanks,
> Dave
>   
> ----- Original Message -----
> From: Dave Everson
> To: Turbine Users List
> Sent: Friday, November 16, 2001 8:32 AM
> Subject: Velocity & Calculating Total Amounts
> 
> 
> Hi - 
> 
> In a Velocity template, I am attempting to generate a total for all the detail
> lines displayed on the page.  However, the total is always displaying zero.
> 
> Here is what my code currently looks like:
> 
> #set($totalBlockScale = 0)
> #foreach ($greenLoadDetail in $load.GreenLoadDetails)
>   #foreach ($packDetail in $greenLoadDetail.PackDetails)
>   <tr>
>      ...cut other columns...
>    <td>$packDetail.blockScale</td>
>    #set($totalBlockScale = $int.valueOf($totalBlockScale) +
> $int.valueOf($packDetail.blockScale))
>  </tr>
> #end
> #end
> 
> <tr>
>  <td colspan="8">Block Scale Total:</td>
>  <td>$totalBlockScale</td>
> </tr>
> 
> This code correctly displays all the detail lines, but the total is always
> displayed as zero.  $packDetail.blockScale does have valid numeric values.  If
> I change the #set($totalBlockScale = 0) line to something like
> #set($totalBlockScale = 5000), then the total is displayed as 5000.  So for
> some reason, each detail line is not incrementing the $totalBlockScale
> variable. 
> 
> Can someone help me with what I am doing wrong?

Anything in the log?  Velocit will bark into the log when it can't or won't
do math (simply put...)

One solution is a little context tool...

-- 
Geir Magnusson Jr.                                     [EMAIL PROTECTED]
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to