[Gambas-user] Class array iterations

Benoit Minisini benoit.minisini at gambas-basic.org
Wed Jan 25 07:54:10 CET 2023

Le 25/01/2023 à 07:18, BB a écrit :
> Class arrays, (in fact any array,) could do with a property to return 
> the index of the current item being pointed at. This would aid in the 
> following case where there are two "parallel" arrays.
> Dim SomeSet as new SomeClass[]
> Dim AnotherSet as new AnotherClass[]
> Dim SomeItem as SomeClass
> Dim AnotherItem as AnotherClass
> '  fill the arrays however, then
> For Each SomeItem in SomeClass[]
>      AnotherItem=AnotherSet[SomeItem.Index]
> ' Then I can process the equivalent items in both arrays
> ...
> Any chance Benoit? I have had a look at gb_array.h and there seems to be 
> a _pos integer used commonly but that code is way above my pay grade.
> I know I could do it using an indexer to perform the iteration but I 
> have "lots" of places where I have used For Each
> bruce

Yes, it's possible, following the same logic as the 'Collection.Key' 


Benoît Minisini.

More information about the User mailing list