[Gambas-user] collection syntax difficulty

Ricardo Díaz Martín oceanosoftlapalma at ...626...
Tue Jun 9 13:07:10 CEST 2009


Maybe the problem is key in collection are String and you are using
MyCollection(999). 

Try:

MyCollection("999") 

to get reference to this element. In adition, when you are adding
elements to MyCollection, convert the key to string
(MyCollection.Add(element, CString(ElementKey))

regards
Ricardo

-----Mensaje original-----
De: richard terry <rterry at ...1946...>
Reply-to: richard terry <rterry at ...1946...>, mailing list for gambas
users <gambas-user at lists.sourceforge.net>
Para: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Asunto: [Gambas-user] collection syntax difficulty
Fecha: Tue, 9 Jun 2009 20:39:17 +1000


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


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user



More information about the User mailing list