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!

Multiple Pass String Parsing

Status
Not open for further replies.

giswzrd

Technical User
May 8, 2001
11
US
I have a database (Oracle8) with two tables of street addresses one of which is updated by another department. The other department uses abbrevations for Street, Avenue, etc. My table does not. I'm trying to generate a report with CR9 of differences in names and numbers only (i.e. - 123 Stetson Road vs 123 Stetson Rd)

The code I'm trying to use is -

LOCAL numberVar X:=1;

WHILE X=1 DO
(X:=0;
(IF InStr ({C.ADDR}, ' ST') <> 0 THEN
(X:=1;
IF Mid ({C.ADDR}, InStr ({C.ADDR}, ' ST'))=' ST' THEN
Replace ({C.ADDR}, ' ST', ' STREET')
ELSE
Replace ({C.ADDR}, ' ST', ' STREET ');
)

ELSE

IF InStr ({C.ADDR}, ' RD') <> 0 THEN
(X:=1;
IF Mid ({C.ADDR}, InStr ({C.ADDR}, ' RD'))=' RD' THEN
Replace ({C.ADDR}, ' RD', ' ROAD')
ELSE
Replace ({C.ADDR}, ' RD', ' ROAD ')
)
))

I get the Error Message - The loop was evaluated more than the maximum number of times allowed.

I think I get the Error because every cycle of the loop reinitializes the {C.ADDR}. I'm stumped as to how to keep the changes made on each iteration.

Any help would be greatly appreciated.
 
I would suggest you expand both addresses into their fullest form and then compare the two results. The expansion forumla would look something like the following. I appreciate you will come up against many other abbreviations when you test this but the principal is sound (I believe!).

Code:
// Convert an existing address line such that all abbreviations are expanded.

StringVar StringToCheck := {Customer.Address1};

// Expand abbreviations:

// Start with the easy ones - those with spaces before and after the abbreviation
StringToCheck := Replace (StringToCheck, &quot; St &quot;, &quot; Street &quot;);
StringToCheck := Replace (StringToCheck, &quot; Rd &quot;, &quot; Road &quot;);
StringToCheck := Replace (StringToCheck, &quot; Av &quot;, &quot; Avenue &quot;);
StringToCheck := Replace (StringToCheck, &quot; Ave &quot;, &quot; Avenue &quot;);

//Next, check the endings
if right(StringToCheck, 3) = &quot; St&quot; then 
    StringToCheck := Replace (StringToCheck, &quot; St&quot;, &quot; Street&quot;);
if right(StringToCheck, 3) = &quot; Rd&quot; then 
    StringToCheck := Replace (StringToCheck, &quot; Rd&quot;, &quot; Road&quot;);
if right(StringToCheck, 3) = &quot; Ave&quot; then 
    StringToCheck := Replace (StringToCheck, &quot; Ave&quot;, &quot; Avenue&quot;);

// Retuurn the result
StringToCheck


Steve Phillips, Crystal Consultant
 
Thanks Steve for pointing me in the correct direction. Sometimes I can't see the trees for the forest!

Pat Rains, GIS Network Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top