Discussion:
[Semediawiki-user] [SOLVED] Expression error when computing with {{#expr: }}... (Yaron Koren)
robbienam .
2017-07-11 09:39:22 UTC
Permalink
Thank you Yaron! Adding the |no html parameter to the Cargo query fixed the
parsing error within {{#expr: }, as you had indicated.

-Robbie McNerney

On Mon, Jul 10, 2017 at 8:07 AM, <
Send Semediawiki-user mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Semediawiki-user digest..."
1. Re: Expression error when computing with {{#expr: }} on an
integer argument obtained from a Cargo query (Yaron Koren)
----------------------------------------------------------------------
Message: 1
Date: Sun, 9 Jul 2017 09:43:30 -0400
Subject: Re: [Semediawiki-user] Expression error when computing with
{{#expr: }} on an integer argument obtained from a Cargo query
<CAGmQEQFxrR-R8DYSX7B52uvF7is7xvPjGWzg9wfHz
Content-Type: text/plain; charset="UTF-8"
Hi Robert,
Fixing this could be as simple as adding a "|no html" parameter to the
https://www.mediawiki.org/wiki/Extension:Cargo/Querying_
data#.23cargo_query
Please let me know if that doesn't work.
-Yaron
On Sat, Jul 8, 2017 at 10:28 AM, Robert McNerney Jr <
I've been getting the following error when attempting to compute
arithmetic expressions using the parser function {{#expr: }} on a
numerical
Expression error: Unrecognized punctuation character " ".
Note: When I copied and pasted the error message from my wikipage into
this email, I see the strange character between the quotes above.
However,
when viewed on my wiki page (local development version, nothing online
Expression error: Unrecognized punctuation character "".
I checked
https://meta.wikimedia.org/wiki/Help:Calculation
and
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions
but did not see something with a blank or unprintable character listed
among known errors with {{#expr: }}.
So it appears there is some unprintable character included in the
}} causing an error, which may be an artifact(?) of the Cargo query
result
format.
I've included a simplified test case example below along with the
behavior
I've observed. Thank you in advance for any suggestions!
My Mediawiki installation is using XAMPP on a Windows 10 laptop. I am
Installed software
Product
Version
MediaWiki<https://www.mediawiki.org/>
1.28.2
PHP<https://php.net/>
5.6.30 (apache2handler)
MariaDB<https://mariadb.org/>
10.1.21-MariaDB
SMW 2.5.2
Page Forms 4.1.2
Cargo 1.3.1
Parser Functions 1.6.0
Variables 2.1.0
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
Here are the details of a simplified test case to illustrate the
behavior.
Page
someNumber
someKeyString
Test Expr
17
BLAH
The above table testExpr is defined by the following code, contained
<noinclude> {{#cargo_declare:_table=testExpr|someNumber=Integer|
someKeyString=String}}<
/noinclude>
<includeonly> {{#cargo_store:_table=testExpr|someNumber={{{
SomeNumber|}}}|someKeyString={{{SomeKeyString|}}} }}< /includeonly>
The single data entry in the above table was created via the following
{{Test expr|SomeNumber=17|SomeKeyString=BLAH}}
Let's use a Cargo query to obtain the value of the numerical field
'someNumber' from the testExpr table row corresponding to the key string
=
{{#cargo_query:tables=testExpr|fields=someNumber|
where=testExpr.someKeyString='BLAH'|format=list}}
RESULT ==> 17
This result looks like a normal number value. However, we cannot compute
with it using #expr parser function. For clarity, first store the value
returned from the above Cargo query in a variable 'x', using the 'list'
{{#vardefineecho:x|{{#cargo_query:tables=testExpr|fields=
someNumber|where=testExpr.someKeyString='BLAH'|format=list}} }}
RESULT ==> 17
{{#expr:{{#var:x}}+1}}
RESULT ==> Expression error: Unrecognized punctuation character " ".
Try again, but first apply formatnum with raw number parameter R to the
{{#expr:{{formatnum:{{#var:x}} |R}} + 1 }}
RESULT ==> Expression error: Unrecognized punctuation character " ".
Same error. So it appears that there is some unprintable character
attached to the number value 17 returned by the Cargo query.
Now try once more, but this time pass the result of the Cargo query
through an "Identity" template (1 => {{{1}}} ) which returns the
identical
{{#vardefineecho:y|{{#cargo_query:tables=testExpr|fields=
someNumber|where=testExpr.someKeyString='BLAH'|format=
template|template=Identity
}} }}
RESULT ==> 17
As per printable output, this appears identical to the value stored in
variable 'x' above. However, we can compute expressions using variable
{{#expr:{{#var:y}}+1}}
RESULT ==> 18
Can anyone explain this behavior to me? How should I tweak my original
cargo query so that the resulting "number" does not have to be passed
through a template to remove whatever mysterious invisible baggage it is
carrying? Thank you in advance!
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Semediawiki-user mailing list
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
--
WikiWorks ? MediaWiki Consulting ? http://wikiworks.com
------------------------------
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
------------------------------
Subject: Digest Footer
_______________________________________________
Semediawiki-user mailing list
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
------------------------------
End of Semediawiki-user Digest, Vol 134, Issue 7
************************************************
Loading...