• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Running totals not working

jeremey_garcia

VIP Member
Good day,

I am trying to get some running totals to work and I am running into issues. Please see the snippet below, as I know I am missing something simple here.

declared:
<?xdoxslt:set_variable($_XDOCTX, 'HoursTotal', 0)?>
<?xdoxslt:set_variable($_XDOCTX, 'GrossTotal', 0)?>

accumulation:
<?xdoxslt:set_variable($_XDOCTX, 'HoursTotal', xdoxslt:get_variable($_XDOCTX, 'HoursTotal') + 1)?>
<?xdoxslt:set_variable($_XDOCTX, 'GrossTotal', xdoxslt:get_variable($_XDOCTX, 'GrossTotal') + 1)?>

display
<?xdoxslt:get_variable($_XDOCTX, 'HoursTotal'?>
<?xdoxslt:get_variable($_XDOCTX, 'GrossTotal'?>

This is just a basic test as I am unable to get it to work using the variables from the XML. Even with this test, I am not getting the number '1' to show on the pdf. Can someone point me to what I am doing incorrectly?

I tried using the example in:
http://www.jdelist.com/vb4/showthread.php/50401-Adding-Conditional-fields-for-Total-in-rtf

and it didn't work.

Thanks!
 

jeremey_garcia

VIP Member
i figured out what I did wrong. I had been trying to declare some variables within a called template, once I moved all declared variables to the main template then the running totals started working.
 
Hi
I am trying to figure out something on these lines.
<?xdoxslt:set_variable($_XDOCTX, 'HoursTotal', xdoxslt:get_variable($_XDOCTX, 'HoursTotal') + 1)?>

if instead of adding 1 in 'HoursTotal', i want to do some computation here and store the result in HoursTotal, is this doable. so i can later use HourTotal variable to do some more calculations.

<?xdoxslt:set_variable($_XDOCTX, 'HoursTotal', xdoxslt:get_variable($_XDOCTX, 'HoursTotal') + ( List_Price * Order_Quantity))?>
can i store the product of these two fields in HoursTotal ???
 
Top