Join(Uniq(Split("aaa bbb ccc ccc ddd")))+@CRLF
Join(Uniq(SPlit("aaa")))+@CRLF
Join(Uniq("aaa"))+@CRLF
;;
;;======================================================================
;;
;;FUNCTION uniq()
;;
;;ACTION Removes duplicates from a sorted, 1-dimension array
;;
;;AUTHOR Glenn Barnas / FRIT-EROC
;;
;;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
;;
;;EXAMPLES $Singles = Uniq($has_dups)
;
Function Uniq($A)
; $TOP is last entry, $X is source pointer, $Y is destination pointer
Dim $Top, $X, $Y
$Top = UBound($A) ; Find size of original array
Dim $WA[$Top] ; Create working array
$Y = 1 ; output array pointer
$WA[0] = CStr($A[0]) ; copy first element
For $X = 1 to $Top
If $WA[$Y - 1] <> $A[$X] ; is current value different from last?
$WA[$Y] = CStr($A[$X]) ; add it to output
$Y = $Y + 1 ; increment output pointer
EndIf
Next
ReDim Preserve $WA[$Y - 1] ; resize output array
$Uniq = $WA ; return the array of unique elements
EndFunction