Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parsing Addresses
Message
 
À
13/04/2001 19:14:28
Steven Herbin
SNH Computing Corporation
Swan Lake, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00495481
Message ID:
00495628
Vues:
9
This message has been marked as the solution to the initial question of the thread.
Hi Steve,

Outlook does a great job of parsing addresses. I'm yet to find a great way of automating it (the address parsing, not Outlook in general), but it just occured to me tha you could create a new contact, pop an address in and read the components back.

So, here's a little routine that demonstrates just that:
* Program....: PARSEADDRESS.PRG
* Version....: 1.0
* Author.....: Andrew Coates
* Date.......: April 15, 2001
* Notice.....: Copyright © 2001 Civil Solutions, All Rights Reserved.
* Compiler...: Visual FoxPro 06.00.8961.00 for Windows
* Abstract...: Parses an address using the outlook address parser.
*              Simply displays components using a message box, but you could populate an object 
*              with the info if you wanted to - wait, you already have an object populated with the info
*              the contact object.
* Usage......: ? ParseAddress("Level 2" + chr(13) + "549-553 Pacific Highway" + chr(13) + "CROWS NEST, NSW 2062")
* Changes....:

lParameters tcAddress

local lcAddress

* simply for testing
lcAddress = iif(vartype(tcAddress) = "C", tcAddress, "PO Box 1510" + chr(13) + "MAROUBRA NSW 2035" + chr(13) + "AUSTRALIA")

#DEFINE olContactItem 2

local oApp, oContact

* create a new contact
oApp = createobject("outlook.application")
oContact = oApp.CreateItem(olContactItem)

* put the address in as a long string
oContact.BusinessAddress = lcAddress

* don't need to call it anything - just use it and discard it!
* oContact.FileAs = "Temp Contact"

* don't even need to save the contact
* oContact.Save

* read the components

MessageBox(oContact.BusinessAddressStreet, 0, "Street")
MessageBox(oContact.BusinessAddressPostOfficeBox, 0, "PO Box")
MessageBox(oContact.BusinessAddressCity, 0, "Suburb")
MessageBox(oContact.BusinessAddressState, 0, "State")
MessageBox(oContact.BusinessAddressPostalCode, 0, "Post Code")
MessageBox(oContact.BusinessAddressCountry, 0, "Country")

* not required because we didn't save
* oContact.Delete
Looks pretty good on the limited testing data I used - I have a feeling that it uses the computer's current country to work out what country to assign if there's not a country in the address.

Cheers,

Andrew

>Does anyone have any examples of address parsing routines?
>
>I have a client whose City State ZIP line is an absolute mess and rather than have them hand code all the changes, I was wondering if the Fox World would have a better way.
>
>Thanks in advance.


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform