| NWN2 Scripting. |
Simulation Training. Introduction Home First Program Seeing Results Variables and Data Types Comments Functions Data Conversion Random Numbers Concatenation Arithmetic Operators Compound Assignments One More or Less Precedence Relational Operators The Open Branch The Closed Branch Logical AND Logical OR Compound Statements ELSE If Switch Case The ? Operator The for Loop The while Loop The do while Loop Introduction to Functions Passing Values Passing Multiple Values Multiple Functions Simplifying Functions TRUE/fALSE Conditions Return Values Setting Global Variables Getting Global Variables Setting Local Variables Getting Local Variables WayPoints Introduction Static Waypoint Sets Dynamic Waypoint Sets Dynamic WP Cycles Input Output |
The Closed BranchThis section illustrates the use of the Closed Branch. The Closed Branch extends the decision-making capabilities of you programs. As you will discover, the closed branch statements are very similar to the open brach statement.
Basic Idea The basic idea behind the Closed Branch is that it will execute one of two options depending on a given condition. What this means is that one of two options will be executed, but not both.
The if...else Statement The if...else Statement is another conditional statement. It differs from the if staement in that the if statement is an open branch where the if..else is an closed branch. The general form of the if..else statement is: if (expression) statement1 else statement2 What this means is that if expression is true then statement1 will be executed. If, on the other hand, expression is false, than statement2 will be executed. This is illustrated in the following program:
The above program compiles without errors. here are some facts about the program:
Where do we go from here? The next section introduces more decision-making techniques with the introduction of the logical AND and the logical OR.
|
|