| 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 while LoopThe while-loop is like the for-loop with the difference being in the for-loop you know the exact numer of times the loop will be repeated, but in th while0loop you do not know ahead of time how many times it will be repeated.
The while loop The basic form of the while loop is shown below
An example of the use of the whie loop is shoawn in the following program:
The above program checks the current game time (the game hour). If the game time is 12 (midnight) then the while-loop initiates and keeps checking the game time. As long as the game time is equal to 12, the message "Boooo!" keeps appearing. Once the game time hour is no longer equal to 12, the while-loop stops. The table below identifies the major parts of the while loop from the program above.
Where do we go from here? The next sections will introduce the do while loop.
|
|