|
|
|
Sample code for using RecogniContact/COM address parser in
Borland Delphi
NOTE!
- Make sure to first import RecogniContact.tlb to Borland Delphi as
decribed here
- Replace [YOUR NAME] and [YOUR LICENSE KEY] with your license
details
- In the main application using RecogniContact.dll, set the maximum
stack size to at least 2 megabytes. (In the Delphi IDE, go to
Project - Options - Linker and set "Max stack sitze" to "2097152"
(decimal) or "$200000" (hexadecimal) )
procedure RecogniContactDemo;
var
parser: IContactParser;
parsedContact: IParsedContact;
parserSettings: IParserSettings;
begin
//create the address parser COM object instance
//---------------------------------------------
parser := CoParser.Create();
if parser=NIL then raise Exception.Create('Error loading RecogniContact.dll');
//initialize address parser
//-------------------------
parser.Initialize('[YOUR NAME]', '[YOUR LICENSE KEY]');
//show remaining license days in parser license
ShowMessage('License Days Left='+parser.GetLicenseInfo(litDaysLeft));
//================================================
//adjusting the address parser settings (optional)
//================================================
//get the address parser settings object
//--------------------------------------
parserSettings:=parser.CreateSettingsObject;
//modify the address parser settings object
//-----------------------------------------
parserSettings.UseCountryFromPlaceName:=true;
parserSettings.TranslateExistingCountryNames:=true;
parserSettings.CountryNameLanguage:=Language_EN;
parserSettings.StandardizePhoneNumberFormat:=true;
parserSettings.InternationalPhoneNumber_IntlAccessCode:='+';
parserSettings.InternationalPhonePrefixFormat := '_(123)_';
parserSettings.MakeAllPhoneNumbersInternational:=true;
parserSettings.MakeAllPhoneNumbersInternational_DefaultCountry:=Country_US;
//activate the new address parser settings
//----------------------------------------
parser.Settings(parserSettings);
//do the address parsing
//----------------------
parsedContact := parser.Parse('Dr. Walter W. Wagoner - Exhibition Manager'+sLineBreak+
'The Museum of Modern Art'+sLineBreak+
'Address: 11 West 53 Street, New York, NY 10019'+sLineBreak+
'Phone: (212) 708-9400'+sLineBreak+
'Email: info@moma.org'+sLineBreak+
'Web: www.moma.org');
//Show the parsed country
//-----------------------
ShowMessage('Country = '+parsedContact.GetValue(ContactFieldType_Country));
{
use
parsedContact.GetValue()
to access the parsed values
}
{you can call parsedContact.GetValue with the following arguments:
-----------------------------------------------------------------
ContactFieldType_Prefix
ContactFieldType_FirstName
ContactFieldType_MiddleName
ContactFieldType_LastName
ContactFieldType_Suffix
ContactFieldType_Company
ContactFieldType_Company2
ContactFieldType_Position
ContactFieldType_StreetAddress1
ContactFieldType_StreetAddress2
ContactFieldType_PostboxAddress
ContactFieldType_PostboxPostCode
ContactFieldType_PostCode
ContactFieldType_PlaceName
ContactFieldType_Province
ContactFieldType_Country
ContactFieldType_Phone1
ContactFieldType_Phone2
ContactFieldType_Mobile
ContactFieldType_Fax
ContactFieldType_Email
ContactFieldType_Url
ContactFieldType_Gender
ContactFieldType_CountryIsoCode}
end;
|