Using round

Hi all,

I wonder if anyone is using the round function in commcare.

I am trying this

        <bind nodeset="/data/talla" type="xsd:double" constraint=".&gt;= 60 and .&lt;= 200" jr:constraintMsg="jr:itext('talla-constraintMsg')" required="true()" />
        <bind nodeset="/data/roundt" type="xsd:double" calculate="round(/data/talla,2)" />

I am getting this:

internal error handling request: <type 'org.javarosa.xpath.XPathUnhandledException'>: org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot handle function 'round'

In both, cloudcare and commcare ODK,

Any ideas?

Thanks in advance,

William

William,

I'm not sure that we currently implement the round() function
https://confluence.dimagi.com/display/commcarepublic/List+of+xpath+functionsbut
in use it is identical to the

int()

function, so you should be able to just use that as a replacement. You'll
need to pass it one argument, though, rather than two. Is the "2" in that
function call attempting to do something?

-Clayton

··· On Tue, Jan 15, 2013 at 10:14 AM, William Aviles Monterrey < wravmon@gmail.com> wrote:

**
Hi all,

I wonder if anyone is using the round function in commcare.

I am trying this

         <bind nodeset="/data/talla" type="xsd:double" constraint=".&gt;=

60 and .<= 200" jr:constraintMsg="jr:itext('talla-constraintMsg')"
required="true()" />

I am getting this:

internal error handling request: <type
'org.javarosa.xpath.XPathUnhandledException'>:
org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot handle
function 'round'

In both, cloudcare and commcare ODK,

Any ideas?

Thanks in advance,

William

i assume it means 'round to 2 decimal places'.

you could do this with int(100*/data/value + .5)/100

··· On Tue, Jan 15, 2013 at 10:55 AM, Clayton Sims wrote:

William,

I'm not sure that we currently implement the round() function
https://confluence.dimagi.com/display/commcarepublic/List+of+xpath+functionsbut in use it is identical to the

int()

function, so you should be able to just use that as a replacement. You'll
need to pass it one argument, though, rather than two. Is the "2" in that
function call attempting to do something?

-Clayton

On Tue, Jan 15, 2013 at 10:14 AM, William Aviles Monterrey < wravmon@gmail.com> wrote:

**
Hi all,

I wonder if anyone is using the round function in commcare.

I am trying this

         <bind nodeset="/data/talla" type="xsd:double" constraint=".&gt;=

60 and .<= 200" jr:constraintMsg="jr:itext('talla-constraintMsg')"
required="true()" />

I am getting this:

internal error handling request: <type
'org.javarosa.xpath.XPathUnhandledException'>:
org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot handle
function 'round'

In both, cloudcare and commcare ODK,

Any ideas?

Thanks in advance,

William

Yes Drew,

I need two decimal places, and I think I could make it work with
this,

I asked because ODK supports that function:

http://opendatakit.org/help/form-design/binding/

Thanks

WIlliam

··· On Jan 15, 9:58 am, Drew Roos wrote: > i assume it means 'round to 2 decimal places'. > > you could do this with int(100*/data/value + .5)/100 > > > > > > > > On Tue, Jan 15, 2013 at 10:55 AM, Clayton Sims wrote: > > William, > > > I'm not sure that we currently implement the round() function > >https://confluence.dimagi.com/display/commcarepublic/List+of+xpath+fu...in use it is identical to the > > > int() > > > function, so you should be able to just use that as a replacement. You'll > > need to pass it one argument, though, rather than two. Is the "2" in that > > function call attempting to do something? > > > -Clayton > > > On Tue, Jan 15, 2013 at 10:14 AM, William Aviles Monterrey < wrav...@gmail.com> wrote: > > >> ** > >> Hi all, > > >> I wonder if anyone is using the round function in commcare. > > >> I am trying this > > >> >> required="true()" /> > >> >> "round(/data/talla,2)" /> > > >> I am getting this: > > >> internal error handling request: >> 'org.javarosa.xpath.XPathUnhandledException'>: > >> org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot handle > >> function 'round' > > >> In both, cloudcare and commcare ODK, > > >> Any ideas? > > >> Thanks in advance, > > >> William

William,

Thanks for the heads up! We'll do our best to integrate these functions to
maintain compatibility in the future.

Sorry about any difficulty, and hopefully the workaround fits your needs.

-Clayton

··· On Tue, Jan 15, 2013 at 4:06 PM, wmonterrey wrote:

Yes Drew,

I need two decimal places, and I think I could make it work with
this,

I asked because ODK supports that function:

Form Logic - ODK Docs

Thanks

WIlliam

On Jan 15, 9:58 am, Drew Roos dr...@dimagi.com wrote:

i assume it means 'round to 2 decimal places'.

you could do this with int(100*/data/value + .5)/100

On Tue, Jan 15, 2013 at 10:55 AM, Clayton Sims cs...@dimagi.com wrote:

William,

I'm not sure that we currently implement the round() function

https://confluence.dimagi.com/display/commcarepublic/List+of+xpath+fu...inuse it is identical to the

int()

function, so you should be able to just use that as a replacement.
You'll
need to pass it one argument, though, rather than two. Is the "2" in
that
function call attempting to do something?

-Clayton

On Tue, Jan 15, 2013 at 10:14 AM, William Aviles Monterrey < wrav...@gmail.com> wrote:

**
Hi all,

I wonder if anyone is using the round function in commcare.

I am trying this

         <bind nodeset="/data/talla" type="xsd:double"

constraint=".>=

60 and .<= 200" jr:constraintMsg="jr:itext('talla-constraintMsg')"
required="true()" />

I am getting this:

internal error handling request: <type
'org.javarosa.xpath.XPathUnhandledException'>:
org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot
handle
function 'round'

In both, cloudcare and commcare ODK,

Any ideas?

Thanks in advance,

William

Hi Clayton

Using int() wit the suggested approach works well.

Thank you all guys for being so supportive,

William

··· From: Clayton Sims Sent: Wednesday, January 16, 2013 2:59 PM To: commcare-users@googlegroups.com Subject: Re: Using round

William,

Thanks for the heads up! We'll do our best to integrate these functions to maintain compatibility in the future.

Sorry about any difficulty, and hopefully the workaround fits your needs.

-Clayton

On Tue, Jan 15, 2013 at 4:06 PM, wmonterrey wravmon@gmail.com wrote:

Yes Drew,

I need two decimal places, and I think I could make it work with
this,

I asked because ODK supports that function:

Form Logic - ODK Docs

Thanks

WIlliam

On Jan 15, 9:58 am, Drew Roos dr...@dimagi.com wrote:

i assume it means 'round to 2 decimal places'.

you could do this with int(100*/data/value + .5)/100

On Tue, Jan 15, 2013 at 10:55 AM, Clayton Sims cs...@dimagi.com wrote:

William,

I'm not sure that we currently implement the round() function

https://confluence.dimagi.com/display/commcarepublic/List+of+xpath+fu...in use it is identical to the

int()

function, so you should be able to just use that as a replacement. You'll
need to pass it one argument, though, rather than two. Is the "2" in that
function call attempting to do something?

-Clayton

On Tue, Jan 15, 2013 at 10:14 AM, William Aviles Monterrey < wrav...@gmail.com> wrote:

**

Hi all,

I wonder if anyone is using the round function in commcare.

I am trying this

         <bind nodeset="/data/talla" type="xsd:double" constraint=".&gt;=

60 and .<= 200" jr:constraintMsg="jr:itext('talla-constraintMsg')"
required="true()" />

I am getting this:

internal error handling request: <type
'org.javarosa.xpath.XPathUnhandledException'>:
org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot handle
function 'round'

In both, cloudcare and commcare ODK,

Any ideas?

Thanks in advance,

William