If |
Top Previous Next |
DescriptionThe If statement contains a block of commands that execute if an expression is evaluated to be true. The If statement always concludes with an End statement. For more information, see the Flow Control Script Reference.
SyntaxGeneric Use Cases
|
If (mySpacecraft.Height < 100); // Executes if myVariable = 1 (true) |
Using Else and ElseIf
If (Variable1 > 5); // ... ElseIf (Variable2 == Variable3); // ... Else; // ... End; |
•It is possible to test for multiple logical conditions using the "and" and "or" operators. See the Flow Control Script Reference for more information.
•An If statement can depend on an unlimited number of conditional statements. Possible relational conditions are: o<, <=, >, >=, ==, !=, IsType
•When the syntax "If (myVariable);" is used, the expression is: oFalse, if myVariable equals zero. oTrue, if myVariable does not equal zero.
•The ElseIf statement can be used to specify alternative conditional statements. oMultiple ElseIf statements may be used within a single If block.
•The Else statement can be used to define a block of commands that execute when the If statement and any ElseIf statements are all evaluated to be false.
•An If statement must be closed with an End statement.
•To create complex logic flow, you can construct nested loops using multiple If commands, along with For and While statements.
•Additional conditional syntax supported in millisecond timing precision mode only: ois, not, very, somewhat, almost, usually (used with FuzzySet object only) o= (equivalent to ==) o~= (equivalent to !=)
•The "then" keyword is optional following the conditional portion of an If statement. |
Left side of expression
•Defines the object, property, or method that is evaluated to determine whether loop contents will be executed oArray element oObject oObject property/method |
Evaluation Type
|
Right side of expression
•Defines the value that the left side of the expression will be tested against |
Script
•Displays the FreeFlyer Script that is generated by the editor •The ellipsis (...) indicates that additional script can be added inside the loop |
Description
•Displays descriptions of the editor and its fields •Description text changes as the mouse pointer moves over the different fields within the editor |
If (mySpacecraft.Height < 100 and mySpacecraft.ElapsedTime >= TIMESPAN(2 days)); // Report "Spacecraft in contact!" if two Spacecraft are in contact If (Spacecraft1.Contact(Spacecraft2)); |
Using Else and ElseIf
If (mySpacecraft.Height < 100);
// Use the Else statement to provide two possible reports If (Spacecraft1.Contact(Spacecraft2)); |
•Flow Control Script Reference