POSITION:028,114
COLOUR:STANDARD
TEXT:00,The increment portion of the "for" statement is an optional feature. If
TEXT:16,left out, the default increment is 1. You can have a negative increment
TEXT:16,value, so the "for" statement counts down instead of up, but set
TEXT:16,the end value of the "for" statement to be smaller than the start value.
TEXT:32,Unlike the "while" statement, the "for" statement cannot be locked into
TEXT:16,an endless loop, because the expression change is handled automatically.
TEXT:16,Also, the index variable cannot be changed by any statements within the
TEXT:16,loop, but it can be referenced for use (such as an element index in a
TEXT:16,sequence). If the value in the index variable is required for later use,
TEXT:16,you should save it in a variable before the loop ends, because both the
TEXT:16,index variable and its value will vanish when the "for" statement ends.
TEXT:16,This temporary index variable has an attribute called "scope", meaning
TEXT:16,it is accessible only for a specific duration in the program . This
TEXT:16,topic will be revisited later in this tutorial. In the meantime, run a
TEXT:16,program demo now to demonstrate how the "for" statement can be used.
