[Gambas-user] I need a hint on how to delete duplicate items in a array
Brought to you by:
gambas
From: herberth g. <her...@gm...> - 2017-08-24 20:39:39
|
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 |