Please enable JavaScript to view this site.

 

void = List_RemoveDuplicates(sListVarName)

 

This macro function is used to remove all the duplicate entries of an existing list.

 

•Duplicates are identified by comparing the complete strings without distinguishing uppercase and lowercase letters.

•The first occurrence of each string is retained, together with its associated number.

•The list does not need to be sorted beforehand. If duplicates are removed, the remaining entries are returned in sorted order. If no duplicates are found, then the list is not modified, and the original order is preserved.

•The associated number values are not used to identify duplicates. Even if duplicate strings have different associated numbers, the number belonging to the first occurrence is retained.

 

Consider the macro code below, which adds some entries to a list, calls List_RemoveDuplicates, and then calls various list functions to get back some information.

List_Clear(sListCountries)
// put some values in the list
List_Add(sListCountries, 'Albania=Albanien', 10133)  // item 1
List_Add(sListCountries, 'Albania=Albanien', 10165)  // item 2 same as 1
List_Add(sListCountries, 'Algeria=Algerien', 10183)  // item 3
List_Add(sListCountries, 'Andorra=Andorra', 10167)   // item 4
List_Add(sListCountries, 'Armenia=Armenien', 10180)  // item 5
// remove duplicates
List_RemoveDuplicates(sListCountries)
// now get some information back from the list
sResult = List_GetString(sListCountries, 1) // 'Albania=Albanien' 
sResult = List_GetString(sListCountries, 2) // 'Algeria=Algerien' 
sResult = List_GetString(sListCountries, 3) // 'Andorra=Andorra' 
sResult = List_GetString(sListCountries, 4) // 'Armenia=Armenien' 

Creation and Destruction of Lists

 

When using lists, don't forget to use the function List_Create to create your list at the top of the macro, and then the function List_Destroy to destroy it at the end of the macro.

 

See also: list macro functions.

 


Topic 178490, last updated on 10-Oct-2026