Definitive guide to logic syntax in CommCare

Hi

Is there a definitive reference guide to the syntax of logical expressions
used in CommCare?

Or does CommCare use the same syntax as one of the mainstream programming
languages? If so, which one?

The reason I ask is that it is in this area where I face most challenges
and although there are examples on Confluence, inevitably one wants to do
something slightly different!

Thanks

Simon

Hey Simon-

You can refer to the XPath syntax https://www.w3.org/TR/xpath/ for a more
comprehensive guide.

-Will

··· On Thu, Feb 4, 2016 at 1:42 AM, Simon Berry wrote:

Hi

Is there a definitive reference guide to the syntax of logical expressions
used in CommCare?

Or does CommCare use the same syntax as one of the mainstream programming
languages? If so, which one?

The reason I ask is that it is in this area where I face most challenges
and although there are examples on Confluence, inevitably one wants to do
something slightly different!

Thanks

Simon


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thank you William and Sheel, these are just what I need.

Two final questions. When should you use single quotation marks around
things and when should you use double quotation marks? Are spaces
significant in logical expressions? (in the olden days we always used
double quotation marks for everything and spaces in the wrong places caused
problems!)

Thanks again.

Simon

··· On Thursday, February 4, 2016 at 6:42:03 AM UTC, Simon Berry wrote:

Hi

Is there a definitive reference guide to the syntax of logical expressions
used in CommCare?

Or does CommCare use the same syntax as one of the mainstream programming
languages? If so, which one?

The reason I ask is that it is in this area where I face most challenges
and although there are examples on Confluence, inevitably one wants to do
something slightly different!

Thanks

Simon

Hi Simon,

We also have a detailed CommCare functions page:
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions

Thanks,
Sheel

··· On Thu, Feb 4, 2016 at 8:33 AM, William Pride wrote:

Hey Simon-

You can refer to the XPath syntax https://www.w3.org/TR/xpath/ for a
more comprehensive guide.

-Will

On Thu, Feb 4, 2016 at 1:42 AM, Simon Berry simon@colalife.org wrote:

Hi

Is there a definitive reference guide to the syntax of logical
expressions used in CommCare?

Or does CommCare use the same syntax as one of the mainstream programming
languages? If so, which one?

The reason I ask is that it is in this area where I face most challenges
and although there are examples on Confluence, inevitably one wants to do
something slightly different!

Thanks

Simon


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sheel Shah
Project Manager | Dimagi
m: +1.781.428.5419 | skype: sheel_shah

Hey Simon,

Both answers depend on the context you’re considering. Generally XPath
expressions will be surrounded by quotes IE

However literal values would also be surrounded by single quotes:

Spaces generally will not matter (i.e. Will be ignored) unless they are
themselves in a string literal.

Of course there are some exceptions but these will generally hold. Also
quotes will usually be correctly escaped if used in the form builder.

Best,
Will

··· On Sat, Feb 6, 2016 at 12:50 AM Simon Berry wrote:

Thank you William and Sheel, these are just what I need.

Two final questions. When should you use single quotation marks around
things and when should you use double quotation marks? Are spaces
significant in logical expressions? (in the olden days we always used
double quotation marks for everything and spaces in the wrong places caused
problems!)

Thanks again.

Simon

On Thursday, February 4, 2016 at 6:42:03 AM UTC, Simon Berry wrote:

Hi

Is there a definitive reference guide to the syntax of logical
expressions used in CommCare?

Or does CommCare use the same syntax as one of the mainstream programming
languages? If so, which one?

The reason I ask is that it is in this area where I face most challenges
and although there are examples on Confluence, inevitably one wants to do
something slightly different!

Thanks

Simon


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This should also be a useful resource:
http://dimagi.github.io/xform-spec/#xpath-paths

··· On 6 February 2016 at 17:00, William Pride wrote:

Hey Simon,

Both answers depend on the context you’re considering. Generally XPath
expressions will be surrounded by quotes IE

However literal values would also be surrounded by single quotes:

Spaces generally will not matter (i.e. Will be ignored) unless they are
themselves in a string literal.

Of course there are some exceptions but these will generally hold. Also
quotes will usually be correctly escaped if used in the form builder.

Best,
Will

On Sat, Feb 6, 2016 at 12:50 AM Simon Berry simon@colalife.org wrote:

Thank you William and Sheel, these are just what I need.

Two final questions. When should you use single quotation marks around
things and when should you use double quotation marks? Are spaces
significant in logical expressions? (in the olden days we always used
double quotation marks for everything and spaces in the wrong places caused
problems!)

Thanks again.

Simon

On Thursday, February 4, 2016 at 6:42:03 AM UTC, Simon Berry wrote:

Hi

Is there a definitive reference guide to the syntax of logical
expressions used in CommCare?

Or does CommCare use the same syntax as one of the mainstream
programming languages? If so, which one?

The reason I ask is that it is in this area where I face most challenges
and although there are examples on Confluence, inevitably one wants to do
something slightly different!

Thanks

Simon


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Simon Kelly
Senior Engineer | Dimagi South Africa