The following example uses some test data for the associative array aCountry, which associates country codes with their names. The function countryName( ) returns the corresponding country name for a particular code, but if the code is not defined, it returns "Unknown country" instead.

aCountry = new AssocArray( )

aCountry[ "USA" ] = "United States of America" // Test data

aCountry[ "RUS" ] = "Russian Federation"

aCountry[ "GER" ] = "Germany"

aCountry[ "CHN" ] = "People's Republic of China"

? countryName( "GER" ) // "Germany"

? countryName( "XYZ" ) // "Unknown country"

function countryName( cArg )

   // Make sure code is defined before trying to reference it 

 return iif( aCountry.isKey( cArg ), aCountry[ cArg ], "Unknown country" )