Olaf Doschke
Programmer
Code:
oCollection = CreateObject("Collection")
Select oCollection.add(recordobject(),Transform(Rand()*100000)) from foxcode into Array garbage
* just to show one sample
loRecord2=oCollection.Item(3)
? loRecord2.UniqueID
Function recordobject()
Local loRecord
Scatter memo name loRecord
Return loRecord
EndFunc
There's just one downside, that VFPs SQL engine always processes the first record twice and so makes one first additional call to oCollection.add(), because it needs to find out the structure of the result cursor.
Therefore you can't use for example foxcode.uniqueid as the key of each collections item (second parameter of Add()), although it's really unique.
The sql result (in this case an array) is just a single boolean column, but you also have a collection of record objects created alongside, starting at oCollection.Item(2).
Bye, Olaf.