Xbasic

REGION_FROM_AREACODE Function

Syntax

C region_from_areacode(* areacode )

Region as C = REGION_FROM_AREACODE( Area_Code as C )

Region as C = REGION_FROM_AREACODE( Area_Code as N )

Arguments

Region

The region for the specified telephone area code as defined by the North American Numbering Plan Administration.

areacode

A 3 digit number or character string.

Description

Returns the region for the specified telephone area code as defined by the North American Numbering Plan Administration (http://www.nanpa.com/).

Discussion

The REGION_FROM_AREACODE() function returns the region for the specified telephone area code as defined by the North American Numbering Plan Administration. The area code may be passed in as either a character or numeric value. If the specified area code is in use and assigned to a specific region, the result will be the 2 letter abbreviation for the North American region served by the specified area code (US state, Canadian province or ISO country code). If the area code is not in use or is not specific to a geographic region (such as 800, 888, 900, etc), an empty string is returned. There are a few exceptions to 2 letter code convention:

345

Returns "Cayman Islands". The ISO country code is "KY" which could be confused with the state of Kentucky so the full name is returned.

600

Returns "Canada" as it is used throughout the country and not in one specific province. The country code CA could be confused with California so the full name is returned.

664

Returns "Montserrat". The ISO country code is "MS" which could be confused with the state of Mississippi so the full name is returned.

667

Returns"YT, NT, NU" as it is shared by these 3 Canadian provinces.

See Also