[Gambas-user] Array Filtering

Dimitris Anogiatis dosida at ...626...
Sun May 24 00:07:55 CEST 2009


Hey guys,

I was wondering if there's a way to filter an array without having to go
through the whole thing

I've been experimenting with the Find method of the String[] but it only
looks for specific values

ie:
------------------------------------------------------------------------------------------
PUBLIC e AS NEW String[]

PUBLIC SUB Form_Open()
e.Add("D1", 0)
e.Add("D9 D7", 1)
e.Add("D3", 2)
e.Add("D2", 3)
e.Add("D4 D2", 4)
END

PUBLIC SUB Button3_Click()

Dim d AS Integer

d = e.Find("D2")
PRINT d

END
------------------------------------------------------------------------------------------
d will get the value 3. However the next value e.Find("D2) will result
to is a -1 (means the item's not found)

my questions are these

1) is it possible to put wildcards in the string Find is looking for?
so for example as to also catch "D4 D2"?

2) is there a workaround so I can only keep the values Find gives
out a result and discard the rest of the array so essentially I get
only those items I want and nothing else?

I use Gambas 2.12 in Debian Lenny (Stable)

Thanks in Advance
Regards
Dimitris



More information about the User mailing list