Article ID: 133453
Article Last Modified on 12/3/2003
FUNCTION addsort
PARAMETER xxx
xxx=ALLTRIM(UPPER(xxx))
wordnum=OCCURS(' ',xxx)+1 && A space between the quotation marks
DIMENSION mychar(wordnum)
mychar='' && No spaces between the quotation marks
yyy='' && No spaces between the quotation marks
x_begin=1
IF LEN(xxx)>0
* The following FOR/NEXT breaks the address down into separate words.
FOR i=1 TO wordnum
x_end=AT(' ',xxx,i)-x_begin && A space between the quotation marks
IF x_end<1 && No spaces in the string
x_end=LEN(xxx)
ENDIF
mychar(i)=SUBSTR(xxx,x_begin,x_end) && single word in address field
x_begin=x_begin+x_end+1
IF x_begin>LEN(xxx)
i=wordnum
ENDIF
ENDFOR
* The following FOR/ENDFOR grabs all the character words and
* build a new string. (1st, 2nd, 3rd, 4th, etc. are considered
* character words.
FOR i=1 TO wordnum
IF ISALPHA(mychar(i))
yyy=yyy+mychar(i)
ENDIF
IF ISDIGIT(mychar(i))
IF 'ST'$mychar(i) .OR. 'ND'$mychar(i) .OR. 'RD'$mychar(i) .OR. ;
'TH'$mychar(i)
yyy=yyy+LEFT('00000000',10-LEN(mychar(i)))+mychar(i)
mychar(i)='' && No spaces between the quotation marks
ENDIF
ENDIF
ENDFOR
* The following FOR/ENDFOR grabs all the numeric words and appends
* it to the end of the new string.
FOR i=1 TO wordnum
IF ISDIGIT(mychar(i)) .AND. .NOT. ;
(INLIST(mychar(i),'ST','ND','RD','TH'))
yyy=yyy+LEFT('00000000',8-LEN(mychar(i)))+mychar(i)
ENDIF
ENDFOR
ELSE
Y=" " && A space between the quotation marks
ENDIF
RETURN(yyy)
INDEX ON addsort(address) TO myidx
Additional query words: FoxWin FoxDos FoxMac VFoxWin
Keywords: kbcode KB133453