This topic contains descriptions of the built-in operators in Autodesk Simulation CFD Scripting.
Note: the information in this section directly references the QT Script for Applications Manual.
Assignment Operators
These operators are used to assign the value of expressions to variables.
= operator
var variable = expression;
The assignment operator is used to assign the value of an expression to the variable.
It is an error to attempt to assign to a constant.
+= operator
variable += expression;
This operator adds the value of the expression to the variable. It is the same as:
variable = variable + expression;
but is shorter to write, and less error-prone.
-= operator
variable -= expression;
This operator subtracts the value of the expression from the variable.
*= operator
variable *= expression;
This operator multiplies the value of the expression by the value of the variable.
/= operator
variable /= expression;
This operator divides the value of the variable by the value of the expression.
%= operator
variable %= expression;
This operator divides the variable by the expression, and assigns the remainder of the division (which may be 0), to the variable.
Arithmetic Operators
These operators are used to perform arithmetic computations on their operands.
+ operator
operand1 + operand2
This operator returns the result of adding the two operands (operand1 and operand2).
++ operator
++operand; // pre-increment
operand++; // post-increment
The pre-increment version of this operator increments the operand, and returns the value of the (now incremented) operand.
The post-incremented version of this operator returns the value of the operand, and then increments the operand.
- operator
var result = operand1 - operand2; // subtraction
operand = -operand; // unary negation
The subtraction version of this operator returns the result of subtracting its second operand (operand2) from its first operand (operand1).
The unary negation version of this operator returns the result of negating (changing the sign) its operand.
-- operator
--operand; // pre-decrement
operand--; // post-decrement
The pre-decrement version of this operator decrements the operand, and returns the value of the (now decremented) operand.
The post-decremented version of this operator returns the value of the operand, and then decrements the operand.
* operator
operand1 * operand2
This operator returns the result of multiplying the two operands (operand1 and operand2).
/ operator
operand1 / operand2
This operator returns the result of dividing the first operand (operand1) by the second operand (operand2).
Note that division by zero is not an error. The result of division by zero is Infinity.
% operator
operand1 % operand2
This operator returns the integer remainder (which may be 0) from the division of operand1 by operand2.
String Operators
These operators provide string functions using operators.
+ string operator
str1 + str2
This operator returns a string that is the concatenation of its operands, (str1 and str2).
+= string operator
str1 += str2
This operator appends its second operand (str2) onto the end of the first operand (str1).
Logical Operators
These operators are used to evaluate whether their operands are true or false in terms of the operator (for unary operators) and in terms of each other (for binary operators).
The binary operators use short-circuit logic, i.e. they do not evaluate their second operand if the logical value of the expression can be determined by evaluating the first operand alone.
&& operator
operand1 && operand2
This operator returns an object whose value is true if both its operands are true; otherwise it returns an object whose value is false.
Specifically, if the value of operand1 is false, the operator returns operand1 as its result. If operand1 is true, the operator returns operand2.
|| operator
operand1 || operand2
This operator returns an object whose value is true if either of its operands are true; otherwise it returns an object whose value is false.
Specifically, if the value of operand1 is true, the operator returns operand1 as its result. If operand1 is false, the operator returns operand2.
! operator
! operand
If the operand's value is true, this operator returns false; otherwise it returns true.
Comparison Operators
These operators are used to compare objects and their values.
== operator
operand1 == operand2
Returns true if the operands are equal; otherwise returns false.
!= operator
operand1 != operand2
Returns true if the operands are not equal; otherwise returns false.
=== operator
operand1 === operand2
Returns true if the operands are equal and of the same type; otherwise returns false.
!== operator
operand1 !== operand2
Returns true if the operands are not equal or if the operands are of different types; otherwise returns false.
> operator
operand1 > operand2
Returns true if operand1 is greater than operand2; otherwise returns false.
>= operator
operand1 >= operand2
Returns true if operand1 is greater than or equal to operand2; otherwise returns false.
< operator
operand1 < operand2
Returns true if operand1 is less than operand2; otherwise returns false.
<= operator
operand1 <= operand2
Returns true if operand1 is less than or equal to operand2; otherwise returns false.