Script Operators |
Top Previous Next |
The operators available in FreeFlyer can be broken up into assignment operators, mathematical operators, logical operators, and String operators. For more information, be sure to see the Matrix, Array, and Variable Math and Flow Control pages.
Assignment OperatorsThe assignment and increment operators can be used with Variables, Arrays, and Matrices. The examples in the table below use the following objects:
The following assignment and increment operators are available in FreeFlyer:
Reference AssignmentWhen something like a Variable declaration is presented elsewhere in the FreeFlyer help documentation, the discussion is specifically referring to the object itself. In this section, there will be a clear delineation between something being an object and something being a reference. Given the advanced nature of this topic, it's recommended that you completely understand Working with Objects before trying to understand references and reference assignments.
When you declare an object, such as a Variable, you're also declaring a reference. Consider the following script.
In the above script, you're declaring a Variable object as well as configuring a reference to that object by the name of 'v1'. Whenever you use 'v1' elsewhere in your script after this point, you're telling FreeFlyer that you want to use the Variable object referred to by the 'v1' reference. You might think on the surface that there's no difference between the reference and the object, but once you get into reference assignments you will realize that you need to treat them differently. Now consider the following script that uses a reference assignment.
In this example, you've declared two objects and configured two references, but then you set the reference v1 to point to the same object as the reference v2. If this were the only script in your Mission Plan, you'd no longer have any references pointing to the object initially declared alongside v1 and that object will get garbage collected as nothing refers to it any longer. This should help clarify the difference between a reference and an object, and alongside reference assignments allows you to achieve some powerful results in your Mission Plans.
Note: The Object.ReferenceEquals() method can be used to check whether two references refer to the same object.
Mathematical OperatorsThe examples in the table below use the following objects:
The following mathematical operators are available in FreeFlyer:
Literal OperatorsThe literal operators described below can be used to conveniently create literal Array or Matrix objects in FreeFlyer script. See the Matrix, Array, and Variable Math page for more information. The examples in the table below use the following objects:
FreeFlyer supports the following literal operators:
Logical OperatorsThe logical operators described below can be used in conjunction with the While and If statements. Nested Flow Control loops can be used to test and handle complex decisions. It is possible to test for multiple logical conditions in a single Flow Control statement by using the logical operators “and” or "or”. The examples in the table below use the following objects.
FreeFlyer supports the following logical operators.
Compound Boolean StatementsCompound Boolean statements containing multiple operators are often used in If and While commands. Boolean expressions now follow standard order of operations. Consider the following script:
Previous to FreeFlyer 6.5, Boolean expressions evaluated left to right. In the script above, this leads to a grouping like: (v == 0 or v == 0) and v == 1
In FreeFlyer 6.5 and higher, the and operator takes precedence over the or operator leading to a grouping like: v == 0 or (v == 0 and v == 1)
In the example given, the expression evaluates to true in FreeFlyer 6.5, but false in previous versions. In FreeFlyer 6.5 and higher, you can also use parentheses to group expressions and explicitly specify the order of evaluation you desire.
String OperatorsThere are a number of String-specific operators that are unique in how they are evaluated. None of the boolean-returning operators below can be used in-line in conditional statements as they all return an Array of boolean values. The examples in the table use the following objects.
FreeFlyer supports the following String operators.
See Also•Matrix, Array, and Variable Math •Parsing Arbitrary String Data
|