removeKey( ) example
The following example loops through an associative array of country names and deletes those whose names are longer than 15 characters.
aTest = new AssocArray( )
aTest[ "USA" ] = "United States of America"
aTest[ "RUS" ] = "Russian Federation"
aTest[ "GER" ] = "Germany"
aTest[ "CHN" ] = "People's Republic of China"
cKey = aTest.firstKey // Get first key in AssocArray
// Get number of elements in AssocArray and loop through them
for nElements = 1 to aTest.count( )
cNextKey = aTest.nextKey( cKey ) // Get next key value before deleting element
if len( aTest[ cKey ] ) > 15
aTest.removeKey( cKey ) // Remove element
endif
cKey := cNextKey // Use next key value
endfor
Note that you must get the next key value before deleting the element, and you repeat the loop based on the number of elements there were before you started deleting.