>** Requires tracy.dbf with same structure you mentioned, plus a field to hold addreess string C(100) > >USE tracy >SCAN > cAddress=tracy.address > > cNumber=GETWORDNUM(cAddress,1) > > cSt_Prefix="" && Might not be one > FOR i = 2 TO GETWORDCOUNT(cAddress) > IF LEN(GETWORDNUM(cAddress,i)) <= 2 && Must be a street prefix > cSt_Prefix=cSt_Prefix+" "+GETWORDNUM(cAddress,i) > ELSE > EXIT && No More > ENDIF > ENDFOR > cStreet = GETWORDNUM(cAddress,i) && After prefix(es), has to be street name > IF LEN(GETWORDNUM(cAddress,i+1)) >= 5 AND UPPER(GETWORDNUM(cAddress,i+1)) # "SUITE" > cStreet=cStreet+" "+GETWORDNUM(cAddress,i+1) > i=i+1 > ENDIF > cSt_type = GETWORDNUM(cAddress,i+1) && After street, has to be type > cTestLast=GETWORDNUM(cAddress,GETWORDCOUNT(cAddress)) > lIsApt=.F. > cApt_Room = "" && Might not be one > FOR j = 1 TO LEN(cTestLast) > IF VAL(SUBSTR(cTestLast,j,1)) > 0 OR LEN(cTestLast) = 1 && Probably an Apt/Ste > lIsApt=.T. > EXIT > ENDIF > ENDFOR > IF lIsApt > cApt_Room = cTestLast > ENDIF > cSt_Suffix = "" > FOR k = GETWORDCOUNT(cAddress) TO i+2 STEP -1 > IF LEN(GETWORDNUM(cAddress,K)) <= 2 AND ; > GETWORDNUM(cAddress,k) # cApt_Room > cSt_Suffix=cSt_Suffix+" "+GETWORDNUM(cAddress,k) > ENDIF > ENDFOR > > cSt_Prefix=CleanIt(cSt_Prefix) > cSt_Suffix=CleanIt(cSt_Suffix) > > REPLACE ; > number WITH cNumber, ; > st_prefix WITH cSt_prefix, ; > street WITH cStreet, ; > st_type WITH cSt_Type, ; > st_Suffix WITH cSt_Suffix, ; > apt_Room WITH cApt_Room >ENDSCAN > > >PROCEDURE CleanIt(cString) >cFixed="" >FOR num = 1 TO GETWORDCOUNT(cString) > cFixed=cFixed+UPPER(LEFT(GETWORDNUM(cString,num),1)) >ENDFOR >RETURN cFixed > >>
>>100 N Main St >>3001 No W Rubick Ave && number=3001, st_prefix = No, Street=W Rubick, st_type = Ave >>12 Sycamore Dairy Rd NW && number = 12, street=Sycamore Dairy, st_type=Rd, st_suffix = NW >>1312 S Cain St E Suite A10 && number = 1313, st_prefix=S, street=Cain, st_type=St, st_suffix=E, apt_room=Suite A10 >>100 N Main St NW Ste 110 >>210 Jones Dr Apt 1E >>8700 Smith Rd >>>>Parse the values typed above into these fields:
>>number c(10) && 100, 3001, 12, 1312, 100, 210, ... >>st_prefix c(10) && NW, S, E, NE... >>street c(30) && Main, Cain, ... >>st_type c(10) && Blvd, ST, AV, ... >>st_suffix c(10) && NW, S, E, NE, ... >>apt_room c(10) && Apt 102, Suite 109, etc... >>>>