Including queries in macros : Understanding the query syntax |
Each query expression yields a result object that belongs to one of the supported types (see Understanding CQL).
Here are some sample query expressions:
• |
1 + 2
|
• |
2 * (2.3 + 1.2)
|
• |
'Hello' + ' world'
|
Each operand in the expression is an object even the constants such as 1
or 'Hello'
, for which the data type is determined automatically. In addition, each object has its own set of members (that is, properties and methods). You can use the following syntax to call an object member:
object.member(parameters) |
Members that do not require any parameters can be called without the parenthetical content, so both of the following expressions are valid:
• |
'world'.length()
|
• |
'world'.length
|
The preceding expression evaluates to a numeric value of 5, the length of the string 'world'
.
In many cases, various properties of the same object must be inspected in an expression. To reduce repetition, a special construct involving square brackets ( []
) can be used:
object[.method1 + .method2 * .method3] |
For example, if you want to evaluate multiple fill-related properties for the current shape, you can use an expression such as the following:
@fill[.type = 'uniform' and .color = 'red'] |
The preceding expression is equivalent to the following expression:
@fill.type = 'uniform' and @fill.color = 'red' |
Similarly, the following example returns TESTtest:
'Test'[.toUpper + .toLower] |
You can include the following operators in your queries:
As in most programming languages, operators have certain precedence:
• |
level 1 . (object method call)
|
• |
level 2 ^
|
• |
level 3 * , / , \
|
• |
level 4 + , -
|
• |
level 5 > , < , = , == , <= , >= , <>
|
• |
level 6 Not , !
|
• |
level 7 And , Or , & , |
|
For example, the expression 2 * 2 + 3
performs the multiplication first and the addition second because the multiplication operator ( *
) has a higher precedence than the addition operator ( +
). To modify the precedence and perform the addition first, you must use parentheses ( ()
) to modify the expression as follows: 2 * (2 + 3)
.
You can use queries to search for shapes, fills, outlines, colors, and global objects. For more information, please see the following topics:
• |
• |
• |
• |
• |
Copyright 2013 Corel Corporation. All rights reserved.