[Gambas-user] To the wish list...

Jussi Lahtinen jussi.lahtinen at ...626...
Fri Aug 21 21:49:05 CEST 2009


Usually string handling is slower than integer, although I haven't
test that in Gambas.

Jussi


On Fri, Aug 21, 2009 at 22:43, Dimitris Anogiatis<dosida at ...626...> wrote:
> Hey Jussi,
>
> If you want to find the duplicate values in an array... give this trick a
> try
>
> 1) turn the array into a string
> 2) store it in a temp string variable
> 3) find the first occurence of the value you want
> 4) put the rest of the string in another temp variable
> 5) do a replace(tempString, "what you want to replace,", "")
> 6) concat the 2 temp strings together
> 7) split the string back into an array
>
> If you notice in step 5 I included the coma in the string you want to
> replace
> and that's because we don't want any duplicate comas it'll screw up the
> splitting process at the end
>
> It's less cpu intensive than doing a for loop to find the duplicates
> (At least I think so, correct me if I'm wrong)
>
> I've used a similar technique to filter certain items from a string array
> don't think this technique would work on other kinds of arrays
>
> I hope it helps
>
> Regards
> Dimitris
>
> On Fri, Aug 21, 2009 at 1:34 PM, M0E Lnx <m0e.lnx at ...626...> wrote:
>
>> What I do also to avoid duplicates is check the array before you add
>> the new entry to it
>>
>> IF MyArray.Find("YourString") = -1 THEN MyArray.Add("YourString")
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> 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