Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
<?lassoscript
/*
pk_math_percentage
by pier kuipers (pier@visualid.com)
modified by bil corry (bil@lasso.biz)
returns the percentage of two numbers
usage: [pk_math_percentage: total, part, precision]
(precision is optional)
*/
if: !(lasso_tagexists:'pk_math_percentage');
define_tag:'pk_math_percentage',
-required='total',
-required='part',
-optional='precision';
did we get a precision?
if:!(local_defined:'precision');
nope, set it to zero
local:'precision' = 0;
/if;
make sure precision is an integer
#precision = integer: #precision;
calculate the percentage
local:'percentage' = decimal:#part / decimal:#total * decimal:100;
format the percentage
#percentage->(setformat: -precision=#precision);
return the percentage
return: #percentage;
/define_tag;
/If;
?>