Rofellos Posted December 23, 2010 Share Posted December 23, 2010 Using functions as _FileListToArray or StringSplit, you may get an array with several duplicate or blank entries. This function removes all duplicate and blank entries, and return a new array (without duplicate and blank entries). It also updates the element of index 0 (number of entries). * It needs to #include <Array.au3> expandcollapse popup; #FUNCTION# ====================================================================================================== ; Name...........: ArrayStripDuplicate ; Description ...: Strips the duplicate items and blank space from given array ; Syntax.........: ArrayStripDuplicate($aArray) ; Parameters ....: $aArray - Input array ; Return values .: Success - The new array ; Failure - -1, sets @error to: ; |1 - $aArray is not an array ; |2 - $aArray is not a 1 dimensional array ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: It needs the #include <Array.au3> ; Related .......: ; Link ..........: ; Example .......: ; ================================================================================================================= Func ArrayStripDuplicate($aArray) Local $aNewArray[1] Local $iArraySize = UBound($aArray) If (Not IsArray($aArray)) Then Return SetError(1, 0, -1) EndIf If (UBound($aArray, 0) <> 1) Then Return SetError(2, 0, -1) EndIf For $i = 1 To ($iArraySize - 1) If (_ArraySearch($aNewArray, $aArray[$i]) = -1) Then _ArrayAdd($aNewArray, $aArray[$i]) EndIf Next $aNewArray[0] = UBound($aNewArray) - 1 Return $aNewArray EndFunc ;==>ArrayStripDuplicate Link to comment Share on other sites More sharing options...
UEZ Posted December 23, 2010 Share Posted December 23, 2010 (edited) What about the build in function _ArrayUnique()? It is slow but working...Br,UEZ Edited December 23, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now