Very nice solution there Bryce. Recommend to add an If $A to the code to remove blank or invalid entry in the return.
Slightly modified code.
Code:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')
Dim $array[0],$List,$File,$A,$B,$Counter
$File = "c:\temp\test.txt"
$List = ReadFile($file)
For Each $A In $list
If $A
For Each $B In $List
If $A = $B
$Counter = $Counter + 1
EndIf
Next
If Ascan($Array,$A + " - " + $Counter) = -1
$Array[UBound($Array)] = $A + " - " + $Counter
ReDim PreServe $Array[UBound($Array)+1]
EndIf
$Counter = 0
EndIf
Next
If UBound($Array)
ReDim PreServe $Array[UBound($Array)-1]
EndIf
? Join($Array,@CRLF)
Function ReadFile($file)
Dim $lf, $f, $_, $t
$lf=chr(10)
$f=freefilehandle
$_=open($f,$file)
if @error exit @error endif
do $t=$t+$lf+readline($f) until @error
$_=close($f)
$ReadFile=split(substr($t,2),$lf)
EndFunction
Code:
Apple
Pear
Orange
Apple
Orange
apple
apple
apple
apple
Orange
Orange
apple
Apple - 2
Pear - 1
Orange - 1
Orange - 3
apple - 5