In This Topic
Logical Functions
AND
Returns TRUE if all its arguments are TRUE; returns FALSE if one or more arguments is FALSE.
Syntax:
AND(logical1, logical2, ...)
logical1 && logical2
logical1 AND logical2
Logical1, logical2, ... are the conditions you want to test that can be either TRUE or FALSE.
- The arguments must evaluate to logical values such as TRUE or FALSE.
- Several formats of the AND operator are available for people familiar with different styles of programming language. All return exactly the same result.
- Note that this function expects Logical arguments, and will convert if necessary. See discussion of Data Types.
Example:
AND(1<10,3+4=7) equals TRUE
OR
Returns TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
Syntax:
OR(logical1, logical2,...)
logical1 || logical2
logical1 OR logical2
Logical1,logical2,... are the conditions you want to test that can be either TRUE or FALSE.
- The arguments must evaluate to logical values such as TRUE or FALSE.
- Several formats of the OR operator are available for people familiar with different styles of programming language. All return exactly the same result.
- Note that this function expects Logical arguments, and will convert if necessary. See discussion of Data Types.
Example:
OR(1<10,1+1=3) equals TRUE
NOT
Reverses the value of its argument. Use NOT when you want to make sure a value is not equal to one particular value.
Syntax:
NOT(logical)
! logical
NOT logical
Logical is a value or expression that can be evaluated to TRUE or FALSE. If logical is FALSE, NOT returns TRUE; if logical is TRUE, NOT returns FALSE.
- NOT is a unary function which means it only works on one operand, which must be a logical value that evaluates to TRUE or FALSE.
- Several formats of the NOT operator are available for people familiar with different styles of programming language. All return exactly the same result.
- Note that this function expects Logical arguments, and will convert if necessary. See discussion of Data Types.
Examples:
NOT(FALSE) equals TRUE
NOT(1+1=2) equals FALSE
Operators
Operators specify the type of calculation that you want to perform on the elements of a formula. CabMasterPro includes four different types of calculation operators: arithmetic, comparison, text, and scope.
Unit Operators
Unit operators allow entry and conversion of real-world units such as lengths, money & time. See the Operators listing.
Arithmetic Operators
Arithmetic operators perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results. You can either use the mathematical symbol (e.g. + or -) or you can use a keyword (e.g. TIMES).
Arithmetic Operator |
Meaning |
Example |
+ or PLUS |
Addition or Positive |
3 + 3 or +8 |
- or MINUS or LESS |
Subtraction or Negation |
3 - 1 or -17 |
* (asterisk) or TIMES |
Multiplication |
3 * 7 |
/ (fwd slash) or DIVIDED BY |
Division |
8 / 2 |
% (percent sign) |
Percent |
20% |
^ (caret) |
Exponentiation |
3 ^ 2 |
Comparison Operators
Comparison operators compare two values and then produce the logical value TRUE or FALSE. You can use the symbols ( =, <, etc) or the text phrases.
All of the key phases can have a 'NOT' inserted after the 'IS' to return the opposite result, e.g. 'IS AT LEAST' and 'IS NOT AT LEAST'. A special case is the 'IS BETWEEN' comparison, when a number is compared to two other values (instead of just one). The EXCLUSIVE word is optional, and the default (INCLUSIVE) is used if it is left out.
If you want to ensure numeric comparisons takes place with the operators > >= < <= (i.e. to force numeric, not string behaviour), use a minus operator and compare the difference to 0, for example...
if FinishedSize.y - FinishedSize.x > 0 then Point[1].x else 0
For string comparisons, "80mm" > "125mm" is true, whereas numeric conversion to length gives 80mm > 125mm which is false. A subtraction forces numeric behaviour, with 80mm - 125mm > 0 comparing -45mm > 0 and giving the result false. This is only applicable to machinestep entry cells which are not strongly typed so they are string cells. In other places, like friendly pages and built in page cells carrying lengths, this concern does not apply.
Comparison Operator |
Meaning |
Example |
= or == or IS or IS EQUAL TO |
Equal to |
A == B |
> or IS GREATER THAN or IS MORE THAN |
Greater than |
A > B |
< or IS LESS THAN or IS FEWER THAN |
Less than |
A < B |
>= IS AT LEAST or IS NOT LESS THAN etc |
More than or equal to |
A >= B |
<= IS AT MOST or IS NOT MORE THAN etc |
Less than or equal to |
A <= B |
<> or != or IS NOT or IS NOT EQUAL TO |
Not equal to |
A != B |
IS BETWEEN x AND y [EXCLUSIVE] |
Between two values |
A is between B and C |
Text Operators
The text operator '&' combine one or more text values to produce a single piece of text.
Text Operator |
Meaning |
Example |
& (ampersand) |
Joins two strings |
"North" & "wind" = "Northwind" |
If you mix text and numeric values, then '&' and '+' behave differently; '+' will attempt convert the text to a number and add it, '&' will convert the numeric to text and then concatenate (join) them.
Scope Operator
The scope operator '.' (full stop) returns a property of another object.
Scope Operator |
Meaning |
Example |
. (period) |
A property of another section |
Container.Width |
Array Operator
The array subscript operator '[ ]' (square brackets) returns a value from an array (see
Arrays).
Array Operator |
Meaning |
Example |
[ ] (square brackets) |
Returns a value from an array |
Dim[1] |
Order of Operations
If you combine several operators in a single formula, CabMasterPro performs the operations in the order shown in the following table. If a formula contains operators with the same precedence (for example, if a formula contains both a multiplication and division operator) CabMasterPro evaluates the operators from left to right. To change the order of evaluation, enclose in parentheses the part of the formula you want to calculate first.
Operator |
Examples |
Units |
$ m deg minutes ft |
Array element |
[ ] |
Scope |
. (full stop) |
Negative and Positive |
+ - |
Percent |
% |
Exponentials |
^ |
Multiplication and Division |
* / |
Addition and Subtraction |
+ - |
Concatenation (text addition) |
& + |
Comparison |
<= > == |
By changing the wording of the formula, you can control how CabMasterPro performs the calculation. For example, the following formula gives a result of 11 because CabMasterPro calculates multiplication before addition: The formula multiplies 2 by 3 (resulting in 6) and then adds 5.
5 + 2 * 3 = 11
In contrast, if you use parentheses to change the syntax, you can first add 5 and 2 together and then multiply that result by 3 for a result of 21.
(5 + 2) * 3 = 21