Query Operators

Old Content - visit altium.com/documentation

The following content has been imported from Legacy Help systems and is in the process of being checked for accuracy.

This section covers Query Operators from the Query Helper dialog in Altium Designer.

Arithmetic Operators

Addition Operator +
Example:
NetPinCount + NetViaCount

Subtraction Operator, -
Example:
ArcStopAngle - ArcStartAngle

Multiplication operator, *
Example:
PadXSize_BottomLayer * PadYSize_BottomLayer

Division Operator, /
Example:
HoleDiameter / ViaDiameter

Integral Division operator, Div
Example:
Color Div 65536
This calculates Color divided by 65536 and the fractional part of the result is discarded.
Mod This is used to obtain the remainder from an integral division operation, equivalent to determining a mathematical modulus.
Example :
Color Mod 256
This calculates the remainder when Color is divided by 256 without determining the fractional part of the result.

Logic Operators

Logical AND operator, And
Logical AND operator, &&

This is also used to implement Logical AND, but has a lower order of precedence.

Examples:
IsPad And OnMultiLayer
IsPad && OnMultiLayer

Logical Or operator, Or
||
This is also used to implement Logical OR, but has a lower order of precedence.
Example:
IsPad Or IsVia
IsPad || IsVia

EXCLUSIVE OR operator, Xor
This is used to implement Logical EXCLUSIVE OR.
Example:
OnMultiLayer Xor (HoleDiameter <> 0)
To be returned, an object has to either be on the Multi-Layer layer and have a Hole Diameter that is zero, or not be on the Multi-Layer layer and have a Hole Diameter that is not zero.

Not This is used to implement Logical NOT.
Example:
Not OnMultiLayer
To be returned, an object has to not be on the Multi-Layer layer.

Comparison Operators

< This means Less Than.
Example:
HoleDiameter < 40

<= This means Less Than Or Equal To.
Example:
HoleDiameter <= 40

>= This means Greater Than Or Equal To.
Example:
HoleDiameter >= 40

> This means Greater Than.
Example:
HoleDiameter > 40

<> This means Not Equal To.
Example:
HoleDiameter <> 40
To be returned, an object has to have a Hole Diameter which is not equal to 40.

= This means Equal To.
Example:
HoleDiameter = 40
To be returned, an object has to have a Hole Diameter which is equal to 40.

Between ... And ... This means Greater Than Or Equal To the first number, and Less Than Or Equal To the second number.
Example:
HoleDiameter Between 30 And 50
To be returned, an object has to have a Hole Diameter that is greater than or equal to 30, and less than or equal to 50.

Like Keywords that are used in conjunction with user-specified strings require that these strings be exactly specified whenever these strings are being compared by the = operator. The use of the Like operator permits the provision of strings which contain one or more Wild Card characters, thus supporting the comparison of strings which are not exactly specified. (See the immediately following Section for a description of Wild Card Characters.)
Example:
Name Like 'ADDR?*'
This returns objects having a Name property whose associated (text) string begins with 'ADDR' and which contains at least one more character; the string property required has thus not been exactly specified, but has been partially specified.

Wild Card Characters

Wild Card characters permit the provision of strings which are not exactly specified. These characters are typically used in conjunction with other characters, resulting in the provision of strings which are partially specified. A few exceptional keywords can accept string parameters that are not exactly specified, but for the most part, strings can only contain Wild Card characters when these are being compared by the Like operator.

? This can be replaced by a single character of any type.
Example:
Footprint Like 'DIP1?'
This returns objects which have a Footprint property of 'DIP10', or 'DIP12', or 'DIP14', etc.

* This can be replaced by any number of characters, each of which can be of any type.
Example:
Footprint Like 'SIP*'
This returns objects which have a Footprint property of 'SIP1', or 'SIP12', or 'SIP216', etc. (Any objects having a Footprint property of 'SIP' are also returned, because *** can also be replaced by no characters.)

Boolean Strings

True This affirms the meaning of a Keyword.
Example:
IsPad = True
To be returned, an object has to be a pad.

False This negates the meaning of a Keyword.
Example:
IsVia = False
To be returned, an object has to not be a via.

Brackets and Order of Precedence

It is highly advisable to use brackets within a query whenever there is any possibility whatsoever that the query might not be correctly interpreted.
The following two queries provide a demonstration of how brackets are used in order to eliminate ambiguity:

((IsPad And OnMultiLayer) Or IsVia) And (HoleDiameter < 16)

(IsPad And OnMultiLayer) Or (IsVia And (HoleDiameter < 16))

Both of those queries return all vias whose hole diameter is less than 16mil, but each of them differs in which pads are also returned. The first query returns pads on the Multi-Layer layer whose hole diameter is less than 16mil, but the second query returns all pads on the Multi-Layer layer, regardless of their hole diameters.
Brackets have the highest precedence within an order of precedence that has been defined for the various operators provided, and which determines how queries are interpreted by the software (whenever the user has not provided brackets). The sequence of this order is as follows:

  • Brackets
  • Not
  • ^,* , /, Div, Mod, And
  • +, -, Or, Xor
  • =, <>, <, >, <=, >=
  • &&, ||

Ambiguities are resolved by working from left to right. Parentheses are evaluated from inside to outside and equal levels are done left to right.
Examples:
A And B Or C becomes (A And B) Or C
A * B + C becomes (A * B) + C

This order of precedence is similar to that used in Pascal type languages. However, generous usage of brackets removes doubt, and makes the resulting queries easier to read by others.

You are reporting an issue with the following selected text and/or image within the active document: