System Query Functions
Contents
- ABS Arithmetic Function
- ACOS Trigonometric Function
- ASIN Trigonometric Function
- ATAN Trigonometric Function
- AVG Aggregate Function
- CEIL Arithmetic Function
- Copy System Function
- COS Trigonometric Function
- COSH Trigonometric Function
- COTAN Trigonometric Function
- EXP Exponential/Logarithmic Function
- FLOOR Arithmetic Function
- FRAC Arithmetic Function
- IIF Arithmetic Function
- INT Arithmetic Function
- Length System Function
- LG Exponential/Logarithmic Function
- LN Exponential/Logarithmic Function
- LOG Exponential/Logarithmic Function
- MAX Aggregate Function
- MIN Aggregate Function
- PI Arithmetic Function
- Pos System Function
- POWER Arithmetic Function
- Pred System Function
- PROD Aggregate Function
- Random System Function
- ROUND Arithmetic Function
- SIGN Arithmetic Function
- SIN Trigonometric Function
- SINH Trigonometric Function
- SQR Arithmetic Function
- SQRT Arithmetic Function
- Succ System Function
- SUM Aggregate Function
- TAN Trigonometric Function
- TANH Trigonometric Function
- TRUNC Arithmetic Function
- ZERO Arithmetic Function
The following content has been imported from Legacy Help systems and is in the process of being checked for accuracy.
This section covers System Query functions (mathematical functions) in Altium Designer. These System Query functions can be used to calculate values and be used for other Query functions.
ABS Arithmetic Function
Description
This function returns a (real) number whose value is equal to the absolute value of the parameter's numeric value. (If that numeric value is positive, the number returned has the same value; otherwise the number returned is equal to the parameter's numeric value multiplied by -1.)
Syntax
ABS(X : Number / Numeric_String) : Number
Examples
ABS(2.3)
Returns 2.3.
ABS(-7.2)
Returns 7.2.
See Also
SIGN Arithmetic Function
ZERO Arithmetic Function
ACOS Trigonometric Function
Description
This function returns a (real) number whose value is equal to the angle of the inverse cosine of the number specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
ACOS(X : Number / Numeric_String) : Number
Examples
ACOS(0)
Returns ~ 1.5708.
ACOS(0.5)
Returns ~ 1.0472.
ACOS(1)
Returns 0.
ASIN Trigonometric Function
Description
This function returns a (real) number whose value is equal to the angle of the inverse sine of the number specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
ASIN(X : Number / Numeric_String) : Number
Examples
ASIN(0)
Returns 0.
ASIN(0.5)
Returns ~ 0.5236.
ASIN(1)
Returns ~ 1.5708.
ATAN Trigonometric Function
Description
This function returns a (real) number whose value is equal to the angle of the inverse tangent of the number specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
ATAN(X : Number / Numeric_String) : Number
Examples
ATAN(0)
Returns 0.
ATAN(1)
Returns ~ 0.7854.
ATAN(2.5)
Returns ~ 1.1903.
AVG Aggregate Function
Description
This function returns a (real) number whose value is equal to the average value of all of the parameters provided. Each parameter must be either a number or a numeric string, and any number of parameters can be provided (as long as at least one parameter is provided).
Syntax
AVG(N1 : Number / Numeric_String) : Number
AVG(N1 , N2 : Number / Numeric_String) : Number
AVG(N1 , N2 , N3 : Number / Numeric_String) : Number
Examples
AVG(2)
Returns 2.
AVG(7,2,3)
Returns 4.
CEIL Arithmetic Function
Description
This function returns an integral number, whose value depends upon the nature of the parameter's numeric value. If that numeric value is an exact integer, the number returned has exactly the same value; otherwise the number returned is the smallest integer that is larger in value than the parameter's numeric value.
Syntax
CEIL(X : Number / Numeric_String) : Number
Examples
CEIL(5.0)
Returns 5.
CEIL(5.33)
Returns 6.
CEIL(-5.0)
Returns -5.
CEIL(-5.33)
Returns -5.
See Also
FLOOR Arithmetic Function
Copy System Function
Description
This function returns a substring of a string. It is possible to specify how many characters will be within the substring returned, and the location within the string which will be the first character of the substring returned.
Syntax
Copy(S : String , Index : Integer , Count : Integer) : String
S is a string-type expression. Index and Count are integer-type expressions. Copy returns a substring containing Count characters starting at SIndex.
If Index is larger than the length of S, Copy returns an empty string.
If Count specifies more characters than are available, only the characters from S[Index] to the end of S are returned.
Examples
Copy('Cats and dogs',1,1)
Returns 'C'. (Return 1 character, from the 1st location within the string.)
Copy('Cats and dogs',2,1)
Returns 'a'. (Return 1 character, from the 2nd location within the string.)
Copy('Cats and dogs',13,1)
Returns 's'. (Return 1 character, from the 13th location within the string.)
Copy('Cats and dogs',14,1)
Returns '' (an empty string). (Return 1 character, from the 14th location within the string; however, there are only 13 characters within the string, so an empty string is returned.)
Copy('Cats and dogs',1,2)
Returns 'Ca'. (Return 2 characters, starting from the 1st location within the string.)
Copy('Cats and dogs',2,2)
Returns 'at'. (Return 2 characters, starting from the 2nd location within the string.)
Copy('Cats and dogs',12,2)
Returns 'gs'. (Return 2 characters, starting from the 12th location within the string.)
Copy('Cats and dogs',13,2)
Returns 's'. (Return 2 characters, starting from the 13th location within the string; however, there are only 13 characters within the string, so only 1 character gets returned.)
Copy('Cats and dogs',15,2)
Returns '' (an empty string). (Return 2 characters, starting from the 15th location within the string; however, there are only 13 characters within the string, so an empty string gets returned.)
Copy('Cats and dogs',1,6)
Returns 'Cats a'. (Return 6 characters, starting from the 1st location within the string.)
Copy('Cats and dogs',5,9)
Returns ' and dogs'. (Return 9 characters, starting from the 5th location within the string.)
Copy('Cats and dogs',8,5)
Returns 'd dog'. (Return 5 characters, starting from the 8th location within the string.)
Copy('Cats and dogs',8,6)
Returns 'd dogs'. (Return 6 characters, starting from the 8th location within the string.)
Copy('Cats and dogs',8,7)
Returns 'd dogs'. (Return 7 characters, starting from the 8th location within the string; however, there are only 13 characters within the string, so only 6 characters get returned.)
COS Trigonometric Function
Description
This function returns a (real) number whose value is equal to the cosine of the angle specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
COS(X : Number / Numeric_String) : Number
Examples
COS(0)
Returns 1.
COS(0.8)
Returns ~ 0.6967.
COS(1.57)
Returns ~ 0.0008.
COSH Trigonometric Function
Description
This function returns a (real) number whose value is equal to the hyperbolic cosine of the parameter's numeric value.
Syntax
COSH(X : Number / Numeric_String) : Number
Examples
COSH(TextHeight / TextWidth) < 70.5
Returns objects for which the hyperbolic cosine of the ratio of their TextHeight distance to their TextWidth distance is less than 70.5. (That is equivalent to returning objects for which the ratio of their TextHeight distance to their TextWidth distance is less than
~ 4.9487.)
(TextHeight / TextWidth) >= COSH(2.3)
Returns objects for which the ratio of their TextHeight distance to their TextWidth distance is equal to or greater than the hyperbolic cosine of 2.3 (which is
~ 5.0372).
COTAN Trigonometric Function
Description
This function returns a (real) number whose value is equal to the cotangent of the angle specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
COTAN(X : Number / Numeric_String) : Number
Examples
COTAN(0.1)
Returns ~ 9.9666.
COTAN(0.8)
Returns ~ 0.9712.
COTAN(1.57)
Returns ~ 0.0008.
EXP Exponential/Logarithmic Function
Description
This function returns a (real) number whose value is equal to e raised to the power of the parameter's numeric value. (The number e is the base of natural logarithms, and is approximately equal to 2.7183.)
Syntax
EXP(X : Number / Numeric_String) : Number
Examples
EXP(0)
Returns 1.
EXP(1)
Returns ~ 2.7183.
FLOOR Arithmetic Function
Description
This function returns an integral number, whose value depends upon the nature of the parameter's numeric value. If that numeric value is an exact integer, the number returned has exactly the same value; otherwise the number returned is the largest integer that is smaller in value than the parameter's numeric value.
Syntax
FLOOR(X : Number / Numeric_String) : Number
Examples
FLOOR(5.0)
Returns 5.
FLOOR(5.33)
Returns 5.
FLOOR(-5.0)
Returns -5.
FLOOR(-5.33)
Returns -6.
See Also
CEIL Arithmetic Function
FRAC Arithmetic Function
Description
This function returns a (real) number, whose value depends upon the nature of the parameter's numeric value.
If that numeric value is positive but is not an exact integer, the number returned is the difference between the parameter's numeric value and the largest integer that is smaller in value than the parameter's numeric value.
If that numeric value is negative but is not an exact integer, the number returned is the difference between the parameter's numeric value and the smallest integer that is larger in value than the parameter's numeric value.
If the parameter's numeric value is an exact integer, the number returned is 0.
Syntax
FRAC(X : Number / Numeric_String) : Number
Examples
FRAC(5.0)
Returns 0.
FRAC(5.33)
Returns 0.33.
FRAC(-5.0)
Returns 0.
FRAC(-5.33)
Returns -0.33.
See Also
INT Arithmetic Function / TRUNC Arithmetic Function
IIF Arithmetic Function
Description
This is a special purpose construction which contains three queries. The value of the first query (between the opening bracket and the first comma) is evaluated. If that is True, the second query (between the commas) is returned; otherwise, the third query (between the second comma and closing bracket) is returned.
This Keyword is similar in concept to "If ... Then ... Else ..." constructions provided with many computer programming languages.
Syntax
IIF(L : Boolean Query , A : Query , B : Query)
L, A, and B are all strings which each specify some Query; L needs to be a Boolean Query (i.e. of a nature that returns either a True or False result).
IIF(L,A,B) has an identical outcome to the Query comprised of:
((L = True) And A) Or ((L = False) And B)
As such, it is especially useful when L is of a complex nature, as it only needs to be specified once.
Examples
IsArc And IIF(ArcStopAngle
- ArcStartAngle >= 0 , ArcStopAngle
- ArcStartAngle Between 30 And 60 , ArcStartAngle
- ArcStopAngle Between 300 And 330)
Returns all arcs that have an arc length which is greater than or equal to 30 degrees and less than or equal to 60 degrees. (The arc length property of an arc is an angle which is determined by subtracting its Start Angle property from its Stop Angle property. A complicating consideration is that it is possible for an arc's Stop Angle property to be smaller than its Start Angle property, but this Query correctly evaluates the true arc length property for all possible arc objects.)
IsComponent And IIF(Layer = 'Top Layer' , Rotation <> 0 , Rotation <> 180)
Returns all components that are on the top side of the PCB whose Rotation property is not 0 degrees, and all components that are on the bottom side of the PCB whose Rotation property is not 180 degrees. (Component objects can only reside on the Top signal layer or Bottom signal layer, so any component which is not on the Top signal layer must then be on the Bottom signal layer instead.)
INT Arithmetic Function
Description
This function returns an integral number, whose value depends upon the nature of the parameter's numeric value.
If that numeric value is positive but is not an exact integer, the number returned is the largest integer that is smaller in value than the parameter's numeric value.
If that numeric value is negative but is not an exact integer, the number returned is the smallest integer that is larger in value than the parameter's numeric value.
If that numeric value is an exact integer, the number returned has exactly the same value.
Note: This is an alias for TRUNC (Arithmetic Function).
Syntax
INT(X : Number / Numeric_String) : Number
Examples
INT(5.0)
Returns 5.
INT(5.33)
Returns 5.
INT(-5.0)
Returns -5.
INT(-5.33)
Returns -5.
See Also
FRAC Arithmetic Function
Length System Function
Description
This function returns the number of characters contained within a string.
Syntax
Length(S : String) : Integer
S is the string whose character count is to be returned.
Examples
Length(Name) Between 4 And 7
Returns objects that have a Name property which contains between 4 and 7 characters.
Length('Cat')
Returns 3.
Length('Darryll')
Returns 7.
Length('Cats and dogs')
Returns 13.
Length('')
Returns 0.
LG Exponential/Logarithmic Function
Description
This function returns a (real) number whose value is equal to the base 10 logarithm of the parameter's numeric value.
Syntax
LG(X : Number / Numeric_String) : Number
Examples
LG(1)
Returns 0.
LG(10)
Returns 1.
LG(25)
Returns
~ 1.3979.
LN Exponential/Logarithmic Function
Description
This function returns a (real) number whose value is equal to the natural (or base e) logarithm of the parameter's numeric value. (The number e is ~ 2.7183.)
Syntax
LN(X : Number / Numeric_String) : Number
Examples
LN(1)
Returns 0.
LN(2)
Returns ~ 0.6931.
LN(10)
Returns ~ 2.3026.
LOG Exponential/Logarithmic Function
Description
This function returns a (real) number whose value is equal to the base 2 logarithm of the parameter's numeric value.
Syntax
LOG(X : Number / Numeric_String) : Number
Examples
LOG(1)
Returns 0.
LOG(2)
Returns 1.
LOG(8)
Returns 3.
LOG(10)
Returns ~ 3.3219.
MAX Aggregate Function
Description
This function returns a (real) number whose value is equal to the maximum value of all of the parameters provided. Each parameter must be either a number or a numeric string, and any number of parameters can be provided (as long as at least one parameter is provided).
Syntax
MAX(N1 : Number / Numeric_String) : Number
MAX(N1 , N2 : Number / Numeric_String) : Number
MAX(N1 , N2 , N3 : Number / Numeric_String) : Number
Examples
MAX(2)
Returns 2.
MAX(7,2,3)
Returns 7.
MIN Aggregate Function
Description
This function returns a (real) number whose value is equal to the minimum value of all of the parameters provided. Each parameter must be either a number or a numeric string, and any number of parameters can be provided (as long as at least one parameter is provided).
Syntax
MIN(N1 : Number / Numeric_String) : Number
MIN(N1 , N2 : Number / Numeric_String) : Number
MIN(N1 , N2 , N3 : Number / Numeric_String) : Number
Examples
MIN(2)
Returns 2.
MIN(7,2,3)
Returns 2.
PI Arithmetic Function
Description
This function returns a (real) number whose value is approximately equal to pi (which is
~ 3.1416, and is the ratio of a circle's circumference to its diameter).
It has been provided because all of the trigonometric functions which have also been provided either return an angle in units of radians, or use a parameter of an angle in units of radians, and there could be times when users would prefer to refer to angles in units of degrees instead.
Syntax
PI : Number
Examples
SIN(PI / 2)
Returns 1.
COS(PI / 3)
Returns 0.5.
TAN(PI / 4)
Returns 1.
Pos System Function
Description
This function returns the index value of the first character in a specified substring that occurs in a given string.
Syntax
Pos(Substr : String , S : String) : Integer
Pos searches for a substring, Substr, in a string, S. Substr and S are string-type expressions.
Pos searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. Pos is case-sensitive. If Substr is not found, Pos returns zero.
Examples
Pos('T',Name) = 1
Returns all objects that have a Name property whose associated string first contains 'T' at its first position; 'T1' and 'Time Table' are examples of such strings. ('T' is located twice within the string 'Time Table', but the first location of this is at its first position.)
Pos('A',Name) = 2
Returns all objects that have a Name property whose associated string first contains 'A' at its second position; 'RA1' and 'CABLE CHART' are examples of such strings.
Pos('B',Name) = 0
Returns all objects that have a Name property whose associated string does not contain 'B' at any position; 'D1' and 'Time Table' are examples of such strings. (The string of 'Time Table' contains 'b' at its eighth position, but Pos is case-sensitive.)
Pos('D',Name) > 0
Returns all objects that have a Name property whose associated string contains 'D' at at least one position and at any location(s); 'Data Chart', 'U1D', and 'Install either D1 and D2 or D3 and D4, but never install all of these.' are examples of such strings.
Pos('Con',Name) = 1
Returns all objects that have a Name property whose associated string first contains 'Con' at its first, second, and third positions; 'Concatenate' is an example of a such string. (The first location of 'Con' within 'Concatenate' is the first three characters of this; the first character within 'Con' is 'C', and its location is the first character of 'Concatenate'.)
Pos('ate',Name) = 5
Returns all objects that have a Name property whose associated string first contains 'ate' at its fifth, sixth, and seventh positions; 'Concatenate' is an example of a such string. (The first location of 'ate' within 'Concatenate' is the fifth through to seventh characters of this; the first character within 'ate' is 'a', and its location is the fifth character of 'Concatenate'.)
Pos('ate',Name) = 0
Returns all objects that have a Name property whose associated string does not contain 'ate' anywhere; 'C1' and 'TIME:' are examples of such strings.
POWER Arithmetic Function
Description
This function returns a (real) number whose value is equal to the first parameter's numeric value raised to the power of the second parameter's numeric value.
Syntax
POWER(X : Number / Numeric_String , Y : Number / Numeric_String) : Number
Examples
POWER(3,2)
Returns 9.
POWER(32,0.2)
Returns 2.
POWER(16,-0.5)
Returns 0.25.
Pred System Function
Description
This function returns a (real) number whose value is equal to parameter's numeric value less 1.0.
Syntax
Pred(X : Number / Numeric_String) : Number
Example
Pred(4.1)
Returns 3.1.
See Also
Succ System Function
PROD Aggregate Function
Description
This function returns a (real) number whose value is equal to the product of all of the parameters provided. Each parameter must be either a number or a numeric string, and any number of parameters can be provided (as long as at least one parameter is provided).
Syntax
PROD(N1 : Number / Numeric_String) : Number
PROD(N1 , N2 : Number / Numeric_String) : Number
PROD(N1 , N2 , N3 : Number / Numeric_String) : Number
Examples
PROD(2)
Returns 2.
PROD(7,2,3)
Returns 42.
Random System Function
Description
Returns a random number between 0 and X-1.
Syntax
Random(Number) : Number
Example
Random(10)
Returns a value between 0 and 9.
ROUND Arithmetic Function
Description
This function returns an integral number, whose value depends upon the nature of the parameter's numeric value.
If that numeric value is an exact integer, the number returned has exactly the same value.
If that numeric value is not an exact integer, the number returned is the integer which is closest in value to the parameter's numeric value. Positive numbers which are exactly midway between adjacent integers are rounded "upwards", while negative numbers which are exactly midway between adjacent integers are rounded "downwards" (see examples below).
Syntax
ROUND(X : Number / Numeric_String) : Number
Examples
ROUND(5.0)
Returns 5.
ROUND(5.33)
Returns 5.
ROUND(5.5)
Returns 6. (Rounded "upwards".)
ROUND(5.66)
Returns 6.
ROUND(-5.0)
Returns -5.
ROUND(-5.33)
Returns -5.
ROUND(-5.5)
Returns -6. (Rounded "downwards".)
ROUND(-5.66)
Returns -6.
See Also
INT Arithmetic Function
SIGN Arithmetic Function
Description
This function Returns sign value of x (=1 if x>0; =0 if x=0; =-1 if x <0). That is, it returns an integral number, whose value depends upon the nature of the parameter's numeric value.
If that numeric value is positive, the number returned is 1.
If that numeric value is negative, the number returned is -1.
If that numeric value is exactly zero, the number returned is 0.
Syntax
SIGN(X : Number / Numeric_String) : Number
Examples
SIGN(5.33)
Returns 1.
SIGN(-5.33)
Returns -1.
SIGN(0)
Returns 0.
See Also
ABS Arithmetic Function
ZERO Arithmetic Function
SIN Trigonometric Function
Description
This function returns a (real) number whose value is equal to the sine of the angle specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
SIN(X : Number / Numeric_String) : Number
Examples
SIN(0)
Returns 0.
SIN(0.8)
Returns ~ 0.7174.
SIN(1.57)
Returns ~ 1.0.
SINH Trigonometric Function
Description
This function returns a (real) number whose value is equal to the hyperbolic sine of the parameter's numeric value.
Syntax
SINH(X : Number / Numeric_String) : Number
Examples
SINH(TextWidth / TextHeight) < 0.17
Returns objects for which the hyperbolic sine of the ratio of their TextWidth distance to their TextHeight distance is less than 0.17. (That is equivalent to returning objects for which the ratio of their TextWidth distance to their TextHeight distance is less than
~ 0.1692.)
(TextWidth / TextHeight) >= SINH(0.2)
Returns objects for which the ratio of their TextWidth distance to their TextHeight distance is equal to or greater than the hyperbolic sine of 0.2 (which is
~ 0.2013).
SQR Arithmetic Function
Description
This function returns a (real) number whose value is equal to the square of the parameter's numeric value.
Syntax
SQR(X : Number / Numeric_String) : Number
Examples
SQR(2)
Returns 4.
SQR(14.1)
Returns 198.81.
SQR(-1.5)
Returns 2.25.
SQRT Arithmetic Function
Description
This function returns a (real) number whose value is equal to the (positive) square root of the parameter's numeric value.
Syntax
SQRT(X : Number / Numeric_String) : Number
Examples
SQRT(4)
Returns 2.
SQRT(10)
Returns ~ 3.1623.
Succ System Function
Description
This function returns a (real) number whose value is equal to parameter's numeric value plus 1.0.
Syntax
Succ(X : Number / Numeric_String) : Number
Example
Succ(2.1)
Returns 3.1.
See Also
Pred System Function
SUM Aggregate Function
Description
This function returns a (real) number whose value is equal to the sum of all of the parameters provided. Each parameter must be either a number or a numeric string, and any number of parameters can be provided (as long as at least one parameter is provided).
Syntax
SUM(N1 : Number / Numeric_String) : Number
SUM(N1 , N2 : Number / Numeric_String) : Number
SUM(N1 , N2 , N3 : Number / Numeric_String) : Number
Examples
SUM(2)
Returns 2.
SUM(7,2,3)
Returns 12.
TAN Trigonometric Function
Description
This function returns a (real) number whose value is equal to the tangent of the angle specified by the parameter's numeric value; that angle is in units of radians (and not degrees).
Syntax
TAN(X : Number / Numeric_String) : Number
Examples
TAN(0)
Returns 0.
TAN(0.8)
Returns ~ 1.0296.
TAN(1.57)
Returns ~ 1255.7656.
TANH Trigonometric Function
Description
This function returns a (real) number whose value is equal to the hyperbolic tangent of the parameter's numeric value.
Syntax
TANH(X : Number / Numeric_String) : Number
Examples
TANH(TextWidth / TextHeight) < 0.17
Returns objects for which the hyperbolic tangent of the ratio of their TextWidth distance to their TextHeight distance is less than 0.17. (That is equivalent to returning objects for which the ratio of their TextWidth distance to their TextHeight distance is less than ~ 0.1717.)
(TextWidth / TextHeight) >= TANH(0.2)
Returns objects for which the ratio of their TextWidth distance to their TextHeight distance is equal to or greater than the hyperbolic tangent of 0.2 (which is ~ 0.1974).
TRUNC Arithmetic Function
Description
This function returns integer part of x (same as INT(x)) that is, it returns an integral number, whose value depends upon the nature of the parameter's numeric value.
If that numeric value is positive but is not an exact integer, the number returned is the largest integer that is smaller in value than the parameter's numeric value.
If that numeric value is negative but is not an exact integer, the number returned is the smallest integer that is larger in value than the parameter's numeric value.
If that numeric value is an exact integer, the number returned has exactly the same value.
Note: This is an alias for INT (Arithmetic Function).
Syntax
TRUNC(X : Number / Numeric_String) : Number
Examples
TRUNC(5.0)
Returns 5.
TRUNC(5.33)
Returns 5.
TRUNC(-5.0)
Returns -5.
TRUNC(-5.33)
Returns -5.
See Also
FRAC Arithmetic Function
ZERO Arithmetic Function
Description
This function returns 0, if x=0 else returns 1, that is, it returns an integral number whose value is either 0 or 1, depending upon the parameter's numeric value. If that numeric value is zero, the number returned is 0; otherwise the number returned is 1.
Syntax
ZERO(X : Number / Numeric_String) : Number
Examples
ZERO(5.33)
Returns 1.
ZERO(-5.33)
Returns 1.
ZERO(0)
Returns 0.
See Also
ABS Arithmetic Function
SIGN Arithmetic Function