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

Benoit Dutilleul benoit.dutilleul at googlemail.com
Sat Jun 7 07:12:01 CDT 2008


Dear Peter, dear Hans,

Thank you for your answers! I've tried MarkupExprPlus and this is
exactly what I needed :) My site is largely using ZAP so I can use
that to save the variable. WikiSh looks interesting as well :) Thanks
for that Peter !

Any idea about if/how I can make calculations using MarkupExprPlus in
a pagelist? I've tried:
[[#SumVotes]]
(:template first:){(add
(:template each:){=$:Var}
(:template last:))}
[[#SumVotesend]]
with the pagelist option wrap=inline but this isn't working. Is it
simply impossible due to the order the markup is processed or is there
a trick to get that to work?

Thanks a lot !

Benoit



2008/6/5 Peter & Melodye Bowers <pbowers at pobox.com>:
>> Subject: [pmwiki-users] Markup or method to increment/decrement a PTV
>> ("integer") variable?
>> Does it exists? How could it be done?
>> Kind regards,
>
> Do you want to change the value temporarily or permanently?  Is it just for
> this load of the page or are you wanting to save it back to the page so it
> will load in its incremented state the next time as well?
>
> If you just want to increment it temporarily for this load then WikiSh
> contains that functionality with the {earlymx(set --ptv ...)} capability.
>
> If you want to save the value back to the page then you're probably going to
> have to come up with a quick function to do it yourself.  If you're
> interested I have recently put together a "toolbox" recipe (toolbox.php)
> which is still under development but it has a function writeptv() which
> would make this job very easy.  It's not yet documented on the cookbook
> page, but the arguments are fairly self explanatory.  This is basically what
> it's going to look like for your functionality:
>
> Function incptv($pagename, $pn, $varname)
> {
>   $val = PageTextVar($pn, $varname);
>   $val++; // or $val--;
>   writeptv($pagename, $pn, $varname, $val);
> }
>
> Then depending on what your desired functionality is you could wrap that in
> an MX or some other markup or just have it in your config.php, etc.
>
> Here's a markup definition of (:incptv page varname:) :
> Markup('IncPTV', 'inline',
>    '/\\(:incptv\s+(\S+)\s+(\S+)\s*:\\)/e',
>    'incptv(\$pagename, "$1", "$2")');
>
> Note this has a bunch of copy/pasted sections of code without any compiling
> or testing.  There will certainly be some fixes needed before any of this
> will work.
>
> -Peter
>
>



-- 
Wanderer, your footsteps are the road, and nothing more; wanderer,
there is no road, the road is made by walking. By walking one makes
the road, and upon glancing behind one sees the path that never will
be trod again. Wanderer, there is no road-- Only wakes upon the sea.
-- Antonio Machado



More information about the pmwiki-users mailing list