Wiki source for KeyPgOpFor


Show raw source

{{fbdoc item="title" value="Operator For (iteration)"}}----
Declares or defines operators used by a ##[[KeyPgFornext|For...Next]]## loop with user defined type variables

{{fbdoc item="syntax"}}##
{ [[KeyPgType|Type]] | [[KeyPgClass|Class]] | [[KeyPgUnion|Union]] } //typename//
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **For** ()
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **For** ( [ [[KeyPgByref|byref]] | [[KeyPgByval|byval]] ] //stp// [[KeyPgAs|as]] //typename// )
//...//
End { [[KeyPgType|Type]] | [[KeyPgClass|Class]] | [[KeyPgUnion|Union]] }
##
{{fbdoc item="usage"}}##
[[KeyPgFornext|For]] //iterator// [ As //typename// ] = //start_value// To //end_value// [ [[KeyPgFornext|Step]] //step_value// ]
[// ...statements... //]
[[KeyPgFornext|Next]]
##
{{fbdoc item="param"}}
##//typename//##
name of the ##[[KeyPgType|Type]]##, ##[[KeyPgClass|Class]]##, or ##[[KeyPgUnion|Union]]##
##//stp//##, ##//step_value//##
a ##//typename//## object used as an incremental value
##//iterator//##
a ##//typename//## object used as an iterator
##//end_value//##
a ##//typename//## object used as a loop-terminating value
##//start_value//##
a ##//typename//## object used to copy construct or assign to the iterator initially

{{fbdoc item="desc"}}
##**Operator For**##, ##[[KeyPgOpNext|Operator Next]]## and ##[[KeyPgOpStep|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 ##[[KeyPgFornext|For...Next]]## loops.
As all non-static member procedures, they have passed a hidden ##[[KeyPgThis|this]]## parameter that allows to access by reference to the iterator object in the code body of the 3 operators.

##**Operator For**## is called immediately after copy constructing or assigning to the iterator object, and allows the object to perform any additional initialization needed in preparation for the loop.

The first version of ##**Operator For**## is used if no step value is given in the ##[[KeyPgFornext|For...Next]]## statement. If a step value is given, the second version is used and is passed the step value because eventual additional initialization may use it.

{{fbdoc item="ex"}}
See the [[KeyPgOpStep|Operator Step]] examples.

{{fbdoc item="lang"}}
- Only available in the //[[CompilerOptlang|-lang fb]]// dialect.

{{fbdoc item="see"}}
- ##[[KeyPgOpNext|Operator Next]]##
- ##[[KeyPgOpStep|Operator Step]]##
- ##[[KeyPgFornext|For...Next]]##

{{fbdoc item="back" value="CatPgOpIterating|Iterating Operators"}}{{fbdoc item="back" value="CatPgOperators|Operators"}}

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode