Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INspects/revers function, address lines

Status
Not open for further replies.

Pootytaint

Programmer
Jan 14, 2005
13
US
I have a program where the incoming address file is 50 bytes long. The problem is there is no delimiter other than space. 123 main st Orlando fl 30992 or PO BOX 23432 CASA GRANDE AZ 85122. I need to move 123 main st to addr1, orlando fl addr2 and 30992 to zip. I figured out how to get the zip out with:

move 0 to ws-tally, ws-data-length.
INSPECT FUNCTION REVERSE(CU-MAIL-ADDR) TALLYING WS-TALLY FOR LEADING SPACES
COMPUTE WS-DATA-LENGTH = LENGTH OF CU-MAIL-ADDR - ws-tally
MOVE CU-MAIL-ADDR(1:WS-DATA-LENGTH) TO WS-HOLD-ZIP1.

My question is what is the best way to read backwards from start of zip to get city/state (also accounting for 'SAN Diego' and move to addr2 and keep going back to move the rest to address1? Any ideas would be appreciated. I have looked through several scenarios on here, but they were'nt quite like this. Thanks!
 
Sorry I meant incoming address field is 50 bytes long.
 
Personally, I think the best way of handling this is to UNSTRING your input into all its individual pieces and then examining each and STRING them back together into a properly formed address.

However, even that is not so simple, because there is no general way to be sure where the street address ends and the city name begins.

For example:

100 McCullogh Ave N Las Vegas, NV 89109

is it "McCullogh Ave N" in "Las Vegas", or is it "McCullogh Ave" in "N Las Vegas".

Not to mention multi-part street addresses. If you are strictly working with US addresses, you can put something together that works about 98% of the time, but if you have to deal with International addresses, you have a much bigger problem on your hands.

You might want to take a look at this thread209-1520795 and thread209-1436990.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
It is only US addresses and I have a list of all of the possible 2 word cities. Not sure how the unstring would work becuase there is not any kind of delimiter. I am reading backwards and have stripped out zip and state so far. Now I am at city.
 
You might have better luck this way:


1. Use a zip table like this:
2. Build a table or index file from the zip code master.

3. Isolate the zip code from every string.

4. From the zip code file, get the city name and unstring
your data into two fields with the city name as a
delimiter. The first field should wind up as the street
address. Note: you probably want to convert everthing to
upper or lower case in both your data and the zip file.

This is not 100% reliable, but I am not sure anything is.
 
That's a great idea. Now I will only need to unstring the address, which will still take some work since, I do not have a delimter.
 
Great idea Mrregan! Now I have zip and addr2, just have to figure out how to get addr1 w/o a delimiter.

123 main st or PO BOX 23432 CASA GRANDE AZ 85122.
 
I like Mrregan's suggestion too! Just keep in mind that many ZIP codes have multiple city names associated with them. For example, 77339 is both Kingwood, TX and Humble, TX. So as Mark said it's not 100% perfect but still pretty good. I haven't checked whether the data file he provided includes alternate names such as these.

My original suggestion was unclear. Where I suggested UNSTRING'ing the input into multiple pieces, I meant using the spaces as delimiters.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
mrregan wrote:
From the zip code file, get the city name and unstring
your data into two fields with the city name as a
delimiter. The first field should wind up as the street
address. Note: you probably want to convert everthing to
upper or lower case in both your data and the zip file.

Can anyone give me some pseudocode for this? Everything I have tried doesn't work. If I have the city, how can I use it as a delimiter? I tried to move the city to a delimiter but it does not work. Should I use perform varying or a unstring? Thanks everyone for your help!
 
Good luck. Several of my doctors' offices are on Calle de la Valencia (4 words) I don't recall any 5-word street names, but I wouldn't at all be surprized to find one.
 
You might consider parsing out the city, state, and zip and keep "the rest" as the "street address".

Suggest you run your actual data thru this and see how close you are.
 
Count the number of characters in the city name before
encountering multiple spaces at the end of the city name.
Example: If you put the city name from the file in a 25 character field and the city name is Santa Fe, you should wind up with a count of 8. Now unstring your data delimited
by city-name (1:ws-count) into work-address, work-rest.
 
Thank you for everyone's input. I lucked out and the customer sent me a decent comma-delimited file that made it a snap!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top