|
|
|
Sample code for using RecogniContact 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
procedure RecogniContactDemo;
var
parser: IContactParser;
parsedContact: IParsedContact;
parserSettings: IParserSettings;
begin
//create the parser COM object instance
//--------------------------------------
parser := CoParser.Create();
if parser=NIL then raise Exception.Create('Error loading RecogniContact.dll');
//register license information in parser
//--------------------------------------
parser.Initialize('[YOUR NAME]', '[YOUR LICENSE KEY]');
//show remaining license days in parser license
ShowMessage('License Days Left='+parser.GetLicenseInfo(litDaysLeft));
//========================================
//adjusting the parser settings (optional)
//========================================
//get the parser settings object
//------------------------------
parserSettings:=parser.CreateSettingsObject;
//modify the 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 parser settings
//--------------------------------
parser.Settings(parserSettings);
//parse the text
//--------------
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;
|