Finding and omitting matching records
I am having trouble with a script meant to identify and omit matching records from a search. The idea is for the script's search to return all the addresses for the various contacts of a given company, and then go through and delete matching records so all I am left with are unique choices--one record for each address.
Here is my current script:
Set Variable [$ID; Contacts::CompanyID]
Go to Layout ["Address Chooser"]
Enter Find Mode 
Set Field [Contacts::CompanyID; $ID]
Perform Find 
Go to Record [First]
Set Variable [$first; Contacts::Address]
Go to Record [Next; exit after last]
Set Variable [$second; Contacts::Address]
If [$first = $second]
Theoretically, the first address should be comparing and omitting records until there is no longer a match, and then the second address becomes the new base for comparison and moves on through the results until finished.
I'd appreciate any ideas to execute this more simply or just how to troubleshoot the script if in fact I'm going at this the right way (just incorrectly).