Operator Next (Iteration)


Determines if a For...Next loop should be terminated

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 }

Usage:
For iterator [ As typename ] = start_value To end_value [ Step step_value ]
[ ...statements... ]
Next

Parameters:
typename
name of the Type, Class, or Union
cond, end_value
a typename object used as a loop-terminating value
stp, step_value
a typename object used as an incremental value
iterator
a typename object used as an iterator
start_value
a 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.
As all non-static member procedures, they have passed a hidden this parameter that allows to access by reference to the iterator object in the code body of the 3 operators.

Operator Next is called every time the iterator object 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 because testing for iterating end may depend on it.

Examples:
See the Operator Step examples.

Dialect Differences:
See also:
Back to Iterating Operators
Back to Operators
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode