|  | For (For modes 2D, 3D, Console) |  Show exampleHide example | It is used when we want to repeat execution of command or block of commands and we know how many times it should repeat. |
Block of commands is repeated while the condition, defined it the header of the cycle, is evaluated as true.
Syntax:for(initialization; condition; modification) command
initialization - used to set initial state of the cycle, and is executed once when the cycle starts,
condition - is evaluated on the start of every loop, when true, the command is executed,
modification (cycle advance) - here is usually (but not necessarily) incremented (or otherwise altered) variable that is present in the condition and that is controlling the iteration.
Five times sets Baltie's coordinate Y to value of variable y nad waits 0.5 second. | | |
|
|
|  | While (For modes 2D, 3D, Console) |  Show exampleHide example | Repeatedly executes command or block of commands while the condition defined in the header of the cycle is evaluated as true. |
The condition is testes before the body of the cycle is executed.
That means if the first condition evaluation is false, cycle will be executed not a single time.
Syntax:while(condition) command
|
|
|  | Do (For modes 2D, 3D, Console) |  Show exampleHide example | Repeatedly executes command or block of commands while the condition defined at the end of the cycle is evaluated as true. |
It means that the body of the cycle is executed once at least.
Syntax:do{command} while(condition)
Baltie n (n is 5) times repeats cycle, in which takes a step and turns n times. Repeats cycle until n is zero. | | |
|
|
|  | Continue (For modes 2D, 3D, Console) |  Show exampleHide example | It is used inside the loop for skipping the remaining commands. Program will continue from the beginning of the current loop. | In this example, Baltie steps forward only 3-times. | | |
|
|
Did you find this information useful?
Documentation of SGP Baltie 4 C#
Send us comments on this topic by
this form
©1978-2010
SGP SystemsParent page |
Previous page |
Next page