Operator Next (Iteration)
Determines if a For...Next loop should be terminated
{ Type | Class | Union } typename
For iterator [ As typename ] = start_value To end_value [ Step step_value ]
typename
cond, end_value
Operator For, Operator Next and Operator Step can be overloaded in user-defined type definitions to allow objects of that type to be used as iterators and step values in For...Next loops.
Operator Next is called every time the iterator needs to be checked against the end value. This happens immediately after the call to its Operator For, and immediately after any calls to its Operator Step. Operator Next should return zero (0) if the loop should be terminated, or non-zero if the loop should continue iterating. The first time Operator Next is called, no statements in the For...Next body, if any, have been executed yet.
The first version of Operator Next is used if no step value is given in the For...Next statement. If a step value is given, the second version is used and is passed the step value.
Syntax
{ Type | Class | Union } typename
Declare Operator Next ( [ ByRef | ByVal ] cond As typename ) As Integer
Declare Operator Next ( [ ByRef | ByVal ] cond As typename, [ ByRef | ByVal ] stp As typename ) As Integer
...
End { Type | Class | Union }Declare Operator Next ( [ ByRef | ByVal ] cond As typename, [ ByRef | ByVal ] stp As typename ) As Integer
...
Usage
For iterator [ As typename ] = start_value To end_value [ Step step_value ]
[ ...statements... ]
NextParameters
typename
cond, end_value
a typename object used as a loop-terminating value
stp, step_valuea typename object used as an incremental value
iteratora typename object used as an iterator
start_valuea typename object used to copy construct or assign to the iterator initially
Description
Operator For, Operator Next and Operator Step can be overloaded in user-defined type definitions to allow objects of that type to be used as iterators and step values in For...Next loops.
Operator Next is called every time the iterator needs to be checked against the end value. This happens immediately after the call to its Operator For, and immediately after any calls to its Operator Step. Operator Next should return zero (0) if the loop should be terminated, or non-zero if the loop should continue iterating. The first time Operator Next is called, no statements in the For...Next body, if any, have been executed yet.
The first version of Operator Next is used if no step value is given in the For...Next statement. If a step value is given, the second version is used and is passed the step value.
Example
Dialect Differences
- Only available in the -lang fb dialect.
See also