Re: [SOLVED] Expression error when computing with {{#expr: }}... (Yaron Koren)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [SOLVED] Expression error when computing with {{#expr: }}... (Yaron Koren)

robbienam .
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, <
[hidden email]> wrote:

> Send Semediawiki-user mailing list submissions to
>         [hidden email]
>
> 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
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Semediawiki-user digest..."
>
>
> Today's Topics:
>
>    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
> From: Yaron Koren <[hidden email]>
> To: Robert McNerney Jr <[hidden email]>
> Cc: "[hidden email]"
>         <[hidden email]>
> Subject: Re: [Semediawiki-user] Expression error when computing with
>         {{#expr: }} on an integer argument obtained from a Cargo query
> Message-ID:
>         <CAGmQEQFxrR-R8DYSX7B52uvF7is7xvPjGWzg9wfHz
> [hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> Hi Robert,
>
> Fixing this could be as simple as adding a "|no html" parameter to the
> #cargo_query call; see here:
>
> 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 <
> [hidden email]> wrote:
>
> > I've been getting the following error when attempting to compute
> > arithmetic expressions using the parser function {{#expr: }} on a
> numerical
> > argument obtained as the singular output of a Cargo query:
> > 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
> > yet), I just see:
> > 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
> {{#expr:
> > }} 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
> > running:
> > 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
> >
> > Some relevant extensions:
> > SMW 2.5.2
> > Page Forms 4.1.2
> > Cargo 1.3.1
> > Parser Functions 1.6.0
> > Variables 2.1.0
> > Also, from my Local Settings file:
> > # 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.
> > Given Cargo table testExpr containing a single data entry row:
> > Page
> >
> > someNumber
> >
> > someKeyString
> >
> > Test Expr
> >
> > 17
> >
> > BLAH
> >
> > The above table testExpr is defined by the following code, contained
> > within the template Template:Test_expr:
> > <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
> > template call:
> > {{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
> =
> > 'BLAH':
> > {{#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'
> > results format for the query:
> > {{#vardefineecho:x|{{#cargo_query:tables=testExpr|fields=
> > someNumber|where=testExpr.someKeyString='BLAH'|format=list}} }}
> > RESULT ==> 17
> > Now try to compute some expression using this variable:
> > {{#expr:{{#var:x}}+1}}
> > RESULT ==> Expression error: Unrecognized punctuation character " ".
> > Try again, but first apply formatnum with raw number parameter R to the
> > variable 'x':
> > {{#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
> > parameter it receives:
> > {{#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
> 'y':
> > {{#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
> > [hidden email]
> > 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>
>
> ------------------------------
>
> End of Semediawiki-user Digest, Vol 134, Issue 7
> ************************************************
>
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Loading...