[Gambas-user] I need a hint on how to delete duplicate items in a array

PICCORO McKAY Lenz mckaygerhard at ...626...
Fri Aug 25 01:09:03 CEST 2017


hey herbert, made it .. only return the local theme: the hint:

https://gambas-playground.proko.eu/?gist=c6e63a84d209911a2b3ff50d2b46a368

Dim sA As String
  Dim i, e As Integer
  Dim ssA As String[] = ["usr/share/Lopez", "Anderson", "Clark", "Wright",
"Mitchell", "Johnson", "Thomas", "Rodriguez"]
  Dim ssB As String[] = ["Johnson", "usr/local/Lopez", "Perez", "Wright",
"Williams", "Smith", "Thomas", "Jones", "Anderson"]
  Dim ssC As New String[]

  For e = ssA.Max To 0 Step -1
    sA = ssA[e]
    For i = ssB.Max To 0 Step -1
        sA = Replace$(sA, "usr/share/", "")
      If InStr(ssB[i],sA,1,gb.Ignorecase) > 0 Then
        ssA.Remove(e)
        ssB.Remove(i)
        ssC.Push(sA)
        Break
      Endif
    Next
  Next
  ssC.Insert(ssA)
  ssC.Insert(ssB)
  ssC.Sort()

  For Each sA In ssC
    Print sA
  Next

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-08-24 18:58 GMT-04:00 PICCORO McKAY Lenz <mckaygerhard at ...626...>:

> thanks gianluigi.. i'm search for same function..
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2017-08-24 18:04 GMT-04:00 Gianluigi <bagonergi at ...626...>:
>
>> I don't know if this can help you.
>> https://gambas-playground.proko.eu/?gist=c6e63a84d209911a2b3ff50d2b46a368
>> Regards
>> Gianluigi
>>
>> 2017-08-24 22:39 GMT+02:00 herberth guzman <herberthguzman at ...626...>:
>>
>> > Hi Benoit, how are you..?
>> >
>> > I have a question, I'm lost
>> > Lol
>> >
>> > I need a hint on how to delete duplicate items in a array
>> >
>> > I have the following function (I send you the code)
>> > And if he works
>> >
>> >
>> > Example
>> >
>> > For Each sDir In ["/usr/share/themes/", Desktop.DataDir &/ "themes/"]
>> >   For Each sNames In RDir(sDir, "*", gb.Directory)
>> >
>> >   Print sNames
>> >
>> >   Next
>> > Next
>> >
>> >
>> > The problem is the following:
>> >
>> > I have /usr/share/themes/Ambiance
>> > I have /home/herberth.local/share/themes/Ambiance
>> >
>> > And I only need one Ambiance
>> > And not two Ambiance
>> >
>> > Please help me solve my problem, I have two days and I can not. I want
>> to
>> > cry.
>> > Lol
>> >
>> >
>> > Attachme my complete code
>> >
>> >
>> >
>> >
>> > Private Function ReturnArrays(SortedArray As String[], withNumber As
>> > Boolean) As String[]
>> >
>> >   Dim sSingle, sWithNumber As New String[]
>> >   Dim i, n As Integer
>> >
>> >   For i = 0 To SortedArray.Max
>> >     ' You can avoid with Tobias's trick (For i = 1 To ...)
>> >     If i < SortedArray.Max Then
>> >       If SortedArray[i] = SortedArray[i + 1] Then
>> >         Inc n
>> >       Else
>> >         Inc n
>> >         sSingle.Push(SortedArray[i])
>> >         sWithNumber.Push(n & SortedArray[i])
>> >         n = 0
>> >       Endif
>> >     Endif
>> >   Next
>> >   Inc n
>> >   sSingle.Push(SortedArray[SortedArray.Max])
>> >   sWithNumber.Push(n & SortedArray[SortedArray.Max])
>> >   If withNumber Then
>> >     Return sWithNumber
>> >   Else
>> >     Return sSingle
>> >   Endif
>> >
>> > End
>> >
>> > Public Sub sListTheme()
>> >
>> >   Dim sDir As String
>> >   Dim sFiles As String
>> >   Dim sSort As String[]
>> >   Dim s As String
>> >
>> >
>> >   For Each sDir In ["/usr/share/themes/", Desktop.DataDir &/ "themes/"]
>> >
>> >     For Each sFiles In Dir(sDir, "*", gb.Directory).Sort()
>> >       sSort = [sFiles]
>> >
>> >         For Each s In ReturnArrays(sSort, 0)
>> >          Print s
>> >         Next
>> >
>> >       Next
>> >   Next
>> >
>> > End
>> >
>> >
>> > If you can help me I'll thank you.
>> > Thank you.
>> > Regards
>> > ------------------------------------------------------------
>> > ------------------
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > _______________________________________________
>> > Gambas-user mailing list
>> > Gambas-user at lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> 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