COLLECTION.NEXT Function

Syntax

A Next(A Key)

Next_Key as C = <COLLECTION>.NEXT( Key as C )

Next_Key as D = <COLLECTION>.NEXT( Key as D )

Next_Key as N = <COLLECTION>.NEXT( Key as N )

Arguments

Key

A value (character, numeric or date) that uniquely identifies an element in a collection.

Description

Return the next element key of the collection.

Discussion

The <COLLECTION>.NEXT() method returns the Next_Key following the specified Key. If the specified Key is the last key in the collection, then the type of the returned key is "Z". To check for the type of the returned key, use the TYPEOF() function.

Example

dim mycollection as u
mycollection.SET("FJ","Fred Jones")
mycollection.SET("BB","Bryan Boyd")
mycollection.SET("KL","Kim Lee")
mycollection.SET("KB","Karen Boyd")
mycollection.SET("EL","Erica Loyd")
? mycollection.GET("BB")
= "Bryan Boyd"
? mycollection.NEXT("BB")
= "KL"
? mycollection.GET("KL")
= "Kim Lee"

The following script prints the data in a collection to the trace window.

mycollection.SET("FJ","Fred Jones")
mycollection.SET("BB","Bryan Boyd")
mycollection.SET("KL","Kim Lee")
mycollection.SET("KB","Karen Boyd")
mycollection.SET("EL","Erica Loyd")
key = mycollection.FIRST()
loop = .T.
while loop
    data = mycollection.get(key)
    trace.writeln(data)
    if (typeof( mycollection.next(key) ) = "Z" ) then
        loop = .f.
    else
        key = mycollection.next(key)
    end if
end while

See Also