WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Small Soundex

Keywords:   Small Soundex 

First define udfStrTranslate:
; This UDF can format number-strings (like phone numbers) and also re-arrange
;the ordering

#DefineFunction udfStrTranslate (sString, sTableIn, sTableOut, sPad)
   If (sTableOut=="") Then If (sTableIn=="") Then Return (StrUpper(sString))
   If (sPad=="") Then sPad = " "
   aArray = ArrDimension(256)
   For i=0 To 255
      aArray[i] = i
   Next
   iLenString = StrLen(sString)
   iLenIn = StrLen(sTableIn)
   sTableOut = StrFix(sTableOut,sPad,iLenIn)
   iLenOut = StrLen(sTableOut)
   For i=1 To iLenIn
      aArray[Char2Num(StrSub(sTableIn,i,1))] = Char2Num(StrSub(sTableOut,i,1))
   Next
   sOut = ""
   For i=1 To iLenString
      sOut = StrCat(sOut,Num2Char(aArray[Char2Num(StrSub(sString,i,1))]))
   Next
   Drop(aArray)
   Return (sOut)
   ; Detlev Dalitz.20020219
#EndFunction


;----------------------------------------------------------
; Soundex und SoundexEx with udfStrTranslate()
;----------------------------------------------------------
Name      = "Ashcraft"
Mode      = 0  ;  0=normal, 1=extended Soundex.
Tabin     = 'WHYEAUIOBFPVCGJKQSXZDTLMNR'
Tabout0   = '00000000111122222222334556'
Tabout1   = '00000000121234435355667889'
Soundex   = StrClean(Name,Tabin,"",@FALSE,2)
Soundex   = StrUpper(Soundex)
Soundex1  = StrSub(Soundex,1,1)
Soundex   = udfStrTranslate(Soundex,Tabin,Tabout%Mode%,"")
Soundex   = StrSub(Soundex,2,-1)
Soundex   = StrCat(Soundex1,Soundex)
Soundex   = StrReplace(Soundex,"0","")
i=2
While i<StrLen(Soundex)
   Char = StrSub(Soundex,i,1)
   Soundex = StrReplace(Soundex,StrCat(Char,Char),Char)
   i=i+1
EndWhile
Soundex   = StrFix(Soundex,"0",4+Mode)
Message(Name,Soundex)
Exit
;----------------------------------------------------------

Article ID:   W15692
File Created: 2003:05:28:10:22:54
Last Updated: 2003:05:28:10:22:54