<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style="text-align: left;">

&gt; <br>&gt; I'll take a look at the snipit you provided. Do you have the original <br>&gt; code handy somewhere, and some time to dig it out for me?<br>&gt; <br>&gt;   ~ ~ Dave<br>&gt; <br>&gt; J. Meijer wrote:<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; Dave,<br>&gt; &gt; <br>&gt; &gt; I have a script that sums row and sums columns putting in a markup in <br>&gt; &gt; the summing row/column and quite a bit smarter then the code below. <br>&gt; &gt; Haven't looked at it in a while.<br>&gt; &gt; <br><br><br>Below you'll find the relevant extract of the script that inserts itself between table markup and the pmwiki table function. <br><br>It
internally reconstructs the table from data within &lt;td&gt; tags. So
it's able to do calculations on it. Hunt for embedded directives like
(:rowtotal:) and (:rowcount:). The difference between the 2 is that
rowtotal rounds to 2 digits (money format), while rowcount expects to
work with integers. <br><br>The recipy could be easily generalized, it was just a quick hack. The number of digits should at least be a parameter. <br><br>We could do much better! <br><br>/jm<br><br><a href="http://applicationmain_11.08.0100.0011.aspx/?culture=en-US&amp;hash=-822026028#" id="EC_EditMessageSendMessageCmd" class="EC_Command FireAnt_Command Web_Bindings_Base ToolBarListHover ButconPressed" target="_blank">
            <span></span></a><br><br>&nbsp; # redine ||cell||, ||!header cell||, ||!caption!|| markup<br>Markup('^||||', 'block', <br>&nbsp; '/^\\|\\|.*\\|\\|.*$/e',<br>&nbsp; "TotalFormatTableRow(PSS('$0'))");<br><br>&nbsp; # reset totals for use between tables<br>Markup('resettotals','^||||',<br>&nbsp; '/[(]:resettotals:[)]/e',<br>&nbsp; 'PZZ($GLOBALS["ColumnTotals"]=array())');<br><br><br><br>function TotalFormatTableRow($x) {<br>&nbsp; global $ColumnTotals;<br>&nbsp; $x=FormatTableRow($x);<br>&nbsp; $y=strip_tags($x,'&lt;td&gt;');<br>&nbsp; if(!preg_match_all('/&gt;(.*?)&lt;\/td&gt;(?:&lt;td|$)/mi',$y,$m)) return $x;<br>&nbsp; $tot=0;<br>&nbsp; foreach($m[1] as $i=&gt;$n) {<br>&nbsp;&nbsp;&nbsp; if(substr($n,-3,1)==',') # undo locale for money format<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $n=str_replace(array('.',',','%+%'),array('%+%','.',','),$n);<br>&nbsp;&nbsp;&nbsp; if(is_numeric($n)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $tot+=$n;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ColumnTotals[$i]+=$n;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>&nbsp; foreach($m[1] as $i=&gt;$c) {<br>&nbsp;&nbsp;&nbsp; if(false!==strpos($c,'(:coltotal:)')) # presume money format<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $x=substr_replace($x,sprintf("%01.2f", $ColumnTotals[$i]),strpos($x,'(:coltotal:)'),12);<br>&nbsp;&nbsp;&nbsp; elseif(false!==strpos($c,'(:colcount:)'))&nbsp; # presume integers<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $x=substr_replace($x,$ColumnTotals[$i],strpos($x,'(:colcount:)'),12);<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<br>&nbsp;&nbsp;&nbsp; $tot+=$ColumnTotals[$i];<br>&nbsp; }<br>&nbsp; foreach($m[1] as $i=&gt;$c) <br>&nbsp;&nbsp;&nbsp; if(false!=strpos($c,'(:rowtotal:)')) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ColumnTotals[$i]+=$tot;<br>&nbsp; $x=str_replace('(:rowtotal:)',sprintf("%01.2f", $tot),$x); # intended for money formats<br>&nbsp; $x=str_replace('(:rowcount:)',$tot,$x); # intended for integers<br>&nbsp; $c=1;<br>&nbsp; $x=preg_replace('/[(]:coltotal:[)]/mie','sprintf("%01.2f", $ColumnTotals[$c++])' ,$x);<br><br>&nbsp; return $x; &nbsp;<br>}<br><br></div><br><br /><hr />Get into the holiday spirit, chat with Santa on Messenger.  <a href='http://imagine-windowslive.com/minisites/santabot/default.aspx?locale=en-us' target='_new'>Ho-Ho-Ho!</a></body>
</html>