[pmwiki-users] MarkupExprPlus calculating with fractions
Martin Kerz
mkerz at me.com
Sun Sep 8 05:42:26 CDT 2013
Okay, in markupexprplus.php I changed line 176 to just give back the variable $expr without doing the eval() stuff.
i.e. from
---
return $expr ? eval("return 0 + ($expr);") : '';
---
to
---
return $expr;
---
In my example:
---
:U:1
:K:0.5
{(add {$:U} {$:K})}:)
---
I now get
---
1)+(0,5
---
without producing an error. As I see it, pmwiki somehow changes the "." to a ",". That might have something to do with my (German) locale. Can I somehow modify the eval() part to get the correct value(s)?
Any tip would be helpful. Thanks a lot.
Martin
On 08 Sep, 2013,at 08:54 AM, Martin Kerz <mkerz at me.com> wrote:
> Okay, I see. There must be something wrong with my installation then, because with the exact same code, I get a
>
> Parse Error in /pmwiki/cookbook/markupexprplus.php(176) : eval()'d code on line 1
>
> Do you have any idea, what might be wrong here? Unfortunately it is (Murphy's law ;-)) 1) mission and time critical and 2) the only bug left.
>
> Martin
>
> On 08 Sep, 2013,at 12:13 AM, Petko Yotov <5ko at 5ko.fr> wrote:
>
>> Martin Kerz writes:
>>> it seems, that it's not possible to calculate with fractions
>>> using MarkupExprPlus.
>>
>> On the page http://www.pmwiki.org/wiki/Cookbook/MarkupExprPlus you can see
>> that operations with decimal numbers are correct.
>>
>> {(add 0.5 4.2 5.9)} correctly prints 10.6
>>
>> Petko
>>
>>> I want to do
>>> (:Sum:{(add {$:U} {$:K})}:)
>>> It works just fine with integers.
>>> Whenever I use a decimal fraction, like
>>> :U:0.5
>>> It produces an error.
>>
>> I have no error with your code. Check if you have 0 'zero' and not O 'letter
>> o'.
>>
>> Petko
>>
>>
>> _______________________________________________
>> pmwiki-users mailing list
>> pmwiki-users at pmichaud.com
>> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20130908/68456ba4/attachment.html>
More information about the pmwiki-users
mailing list