English

How To: Make RemoveDuplicates request case sensitive

Summary

The Avenue request aList.RemoveDuplicates is not case sensitive. This is because aString = aString is not case sensitive. The following script will perform the same task as aList.RemoveDuplicates but is case sensitive.

Procedure

Copy and paste the script below into a New Script window.

Code:
'-- This script will perform the same function as aList.RemoveDuplicates
'-- except that it is case sensitive. This is accomplished by comparing ASCII
'-- values of individual characters once the strings being compared have already
'-- been determined to be equal.

oldlist = self
newlist = {}
for each item_a in oldlist
different = true
for each item_b in newlist
if(item_a = item_b) then
different = false
if(item_a.is(string)) then
for each apos in 1..item_a.count
if(item_a.right(apos).asascii <> item_b.right(apos).asascii) then
different = true
break
end
end
end
end
end
if(different) then
newlist.add(item_a)
end
end
return newlist

This script must be called from another script with the object sent to the script being the list to be processed. For example:

Code:
OldList = {1,2,3,4,5,6,7,8,9,2,4,6,8}
Msgbox.listasstring(OldList,"Has Duplicates","The Old List")
newlist = av.run("Script1", oldlist)
Msgbox.listasstring(newlist,"No Duplicates","The New List")