FOR ... ENDFOR Command
Executes a set of commands a specified number of times.
FOR VarName = nInitialValue TO nFinalValue [STEP nIncrement] Commands [EXIT] [LOOP] ENDFOR | NEXT |
Parameters
- VarName
-
Specifies the name of the variable to act as the counter. The counter keeps track of the number of times the Visual FoxPro commands execute inside the FOR ... ENDFOR loop. The variable does not need to exist before executing FOR ... ENDFOR.
- nInitialValueTO nFinalValue
-
Specifies the initial and final values of the counter. Both nInitialValue and nFinalValue can be array elements.
- [STEP nIncrement]
-
Specifies the amount to increment or decrement the counter value. If nIncrement is negative, the counter value is decremented. If you omit the STEP clause, VarName increments by 1.
- Commands
-
Specifies the Visual FoxPro commands to execute. Commands can include any number of commands.
- [EXIT]
-
Transfers control from within the FOR ... ENDFOR loop to the command immediately following ENDFOR. You can place EXIT anywhere between FOR and ENDFOR. For more information, see EXIT Command.
- [LOOP]
-
Returns control to the FOR clause without executing the statements between the LOOP and ENDFOR keywords. The counter value increments or decrements as if ENDFOR was reached. For more information, see LOOP Command.
- ENDFOR
-
Specifies the end of the FOR ... ENDFOR loop.
- NEXT
-
Specifies the location to continue program execution after the counter value exceeds nFinalValue.
Remarks
Example
See Also
© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic
Note
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08