;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       uniq() 
;; 
;;ACTION         Removes duplicates from a 1-dimension array 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION	 2.0  - 2014/01/13 
;; 
;;HISTORY        1.0  - 2003/02/19 - Initial Release 
;;               1.1  - 2008/06/08 - added error check 
;;               2.0  - 2014/01/13 
;;                rewrite to eliminate requirement that the array be sorted. 
;; 
;;SYNTAX         uniq(array) 
;; 
;;PARAMETERS     array - array to remove duplicates from 
;; 
;;REMARKS        Array must be sorted first - no check for sort is performed 
;; 
;;RETURNS        array with duplicate items removed 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    NT4, W2K, WXP, W2K3, W2K8, W2K12, Win7, Win8 
;;               Explicit, NoVarsInStrings 
;; 
;;EXAMPLES       $aData = Split('red blue orange red green yellow blue red white black purple', ' ') 
;;               1 + UBound($aData) ' elements in array' @CRLF 
;;               $aData = Uniq($aData) 
;;               1 + UBound($aData) ' unique elements in array:' @CRLF 
;;               Join($aData, @CRLF) @CRLF 
; 
Function Uniq($_aSrc)
 
  Dim $_aUniq						; output array 
  Dim $_I, $_O						; Array Index pointers 
  Dim $_P						; Lookup Pointer 
 
  If VarType($_aSrc) < 8192 Exit 87 EndIf		; must pass an array 
 
  $_O = -1						; init the output pointer 
 
  For $_I = 0 To UBound($_aSrc)				; enumerate the source array 
    If AScan($_aUniq, $_aSrc[$_I]) = -1			; If the source value is not in the target array 
      $_O = $_O + 1					; increment the output array pointer 
      ReDim Preserve $_aUniq[$_O]			; enlarge the output array 
      $_aUniq[$_O] = $_aSrc[$_I]			; add the source value to the output array 
    EndIf
  Next
 
  $Uniq = $_aUniq					; return the unique arrray 
  Exit 0
 
EndFunction