This is an old revision of the document!
Query expression
A query can be used as an expression if it is enclosed in asterisked parentheses like (* f:F, g:F, ((f != g), (distance(f, g) < 1)) *) .
XL context queries e.g. (*F*) (loop over all F) can be used either to access a field of each of the queried nodes directly (e.g. (*F*).length) or to create query variables (e.g. (*f:F*)). They can be used in Java blocks.
For example ((*f:F*),f.length/f.diameter) would loop over each F and return the ratio of length to diameter. The result can then be used the same way as (*F*).length, e.g. with the Analytical Operators.
It is also possible to create several query variables, here for the average change in length from one F to the next F:
float m =mean(((*f1:F > f2:F*),f2.length/f1.length));
This can be combined with any other expression, yet it is important to keep in mind that the expressions on the right of the context query are repeated for each found pattern!
Therefore (int i=0,i++,(*F*),i*=2) and (int i=0,(*F*),i++,i*=2) would have different values, because in the first one i++ is only called once and in the second one its called for every F in the scene.
