[pmwiki-users] Markup or method to increment/decrement a PTV ("integer") variable?

Hans design5 at softflow.co.uk
Thu Jun 5 16:43:09 CDT 2008


Thursday, June 5, 2008, 10:17:55 PM, Benoit Dutilleul wrote:

> Markup or method to increment/decrement a PTV ("integer") variable?
> Does it exists? How could it be done?

You could use Cookbook.MarkupExprPlus
which got a {(add num1 num2)} expression.
so {(add num 1)} would add 1 to a number 'num'.

Or you could add this to config.php:

# add {(inc ...)} markup expression
$MarkupExpr['inc'] = 'MxInc($args[0])';
function MxInc ($arg) {
        if(!is_numeric($arg)) return $arg;
        return $arg + 1;        
}       

use like {(inc num)} will show 1 added to num.

'num' can be a PTV.

If you want the PTV updated, i.e increase by one and save,
you could do it for instance with a Fox form, and use one of the
methods above, but in form {$$(inc {$:ptv}}
or  {$$(add {$:ptv} 1}

  ~Hans




More information about the pmwiki-users mailing list