[Gambas-user] collection syntax difficulty

richard terry rterry at ...1946...
Tue Jun 9 12:39:17 CEST 2009


Gambas DOC: Returns the key of the last read or last enumerated element.


I'm having problem reading the key of a collection with collection.key. I 
guess gambas is behaving as gambas says it will, however it would be nice to 
be able to get the first key in a collection without having to iterate 
through it (ie having the default action of  collection.key to return the 
first key).

Lets say I have a collection called myCollection which I've loaded with 
database information keyed on the primary key of the table.

Mycollection(999)

If try and get the key of this by this syntax:
	print Mycollection.key
then the key is null

If I do either
	With Mycollection
		print Mycollection.key
	next
or

For each Mycollection
	print Mycollection.key
next

then it prints the key (here 999)

So my question, short of iterating through a collection (even if only one 
member) is there no way to get the key of the collection? Docs I guess say 
not, is this fixable/changeable?

Richard





More information about the User mailing list