[pmwiki-users] Can't use {(substr )} with the {(calc )} recipe
Petko Yotov
5ko at 5ko.fr
Fri Jan 17 03:54:15 CST 2014
James DeVain writes:
> Hi, everyone. I'm using the "{(calc)}" recipe at
> Cookbook/MarkupExpressionSamples. I'm
> trying to do this:
>
> (:gen:4708003830:)
> {(calc '(substr {$:gen} 0 -8) + 3')}
>
> which should return 50, but I just get "input error!". I've tried it a bunch
> of different
> ways, but nothing works so far. Might be worth mentioning that if I use the
> "{(math)}"
> recipe (from the same page), as in:
>
> {(math (substr {*$:gen} 0 -8) + 3)}
Remove the single quotes. To nest markup expressions use
{(func1 (func2 12 6 (func3 5)) )}
If you use quotes, the stuff in quotes is not searched for nested markup
expressions.
OTOH if you do arithmetic calculations, you may have to use parentheses, and
parentheses indicate sub-expressions. Two ways to use arithmetic parentheses
without quotes and without the markup expressions engine to break:
{(calc 25 + ( {$:stuff}-0) )} use a space after the ( parenthese
{(calc 25 + (calc {$:stuff}-0) )} use an actual sub-expression
Petko
More information about the pmwiki-users
mailing list