*/* Program to parse out an address from a field to city, state, zip. clos data all LOCAL doIt, nCount USE "YourTable" nCount = 0 SCAN doIt=0 for i = 1 to 50 &&the length of YourField or the length of the longest entry if substr("YourField",i,1)=="," cityTemp=substr(YourField,1,i-1) if (substr(YourField,i+3,1)==" " ; or (substr(YourField,i+4,1)==" " ; stateTemp=substr(YourField,i+1,3) zipTemp=alltrim(substr(YourField,i+5,len(YourField))) replace city with alltrim(cityTemp) replace state with alltrim(statetemp) replace zip with alltrim(ziptemp) exit else doIt=i endif endif endfor if doIt<>0 stateZip(alltrim(substr(citysold,doIt+1,len(citysold)))) doIt=0 endif ********************************** procedure stateZip(szVal) split=0 for j = 0 to len(szVal)-1 if substr(szVal,len(szVal)-j,1)==" " split=j exit endif endfor replace city with alltrim(cityTemp) replace state with alltrim(substr(szVal,1,len(szVal)-split)) replace zip with alltrim(substr(szVal,len(szVal)-split,len(szVal))) endproc