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

herberth guzman herberthguzman at ...626...
Mon Aug 28 19:19:22 CEST 2017


Thank you all for helping me.
Solve my problem, now it works fine. I show the code how it works.

  Dim sResult_Theme As String
  Dim sA As String
  Dim i, e As Integer
  Dim ssA As String[]
  Dim ssB As String[]
  Dim ssC As New String[]
  Dim sListUser As String
  Dim sListShare As String

 ssA = New String[]
 For Each sDir In Dir("/usr/share/themes", Null, gb.Directory)
    ssA.Add(sDir)
  Next

  ssB = New String[]
  For Each sListUser In Dir( Desktop.DataDir &/ "themes/", Null,
gb.Directory)
    ssB.Add(sListUser)
  Next

  For e = ssA.Max To 0 Step -1
    sA = ssA[e]
    For i = ssB.Max To 0 Step -1
      If sA = ssB[i] 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.Sort(gb.Ascent)
    Print sA
  Next


Regards


> >This code suggested by Vuott of Gambas-it.org, it only uses the two
> arrays.
> > http://www.gambas-it.org/smf/index.php?topic=5876.msg42088#msg42088
>
> >Regards
> >Gianluigi
>
> >2017-08-25 0:58 GMT+02: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=
> c6e63a84d209911a2b3ff50d2b46a3
> > 68
> > > 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
> > >
> > ------------------------------------------------------------
> > ------------------
> > 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
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
> ------------------------------
>
> End of Gambas-user Digest, Vol 135, Issue 89
> ********************************************
>



More information about the User mailing list