home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
clarion
/
soundex.zip
/
SOUNDEX.CLA
< prev
next >
Wrap
Text File
|
1989-02-01
|
2KB
|
93 lines
member ('test')
omit ('**end**')
------------------------------------------------------------------------------
Name soundex - determines soundex value for a given string
Usage func (soundex), string
Description This soundex value will be the same as values for
similar sounding names. The code consists of the first
letter of the name, followed by three digits.
Developed with Clarion 2.0, batch 2006
Return value soundex returns a string(5) containing the
computed soundex value of the string passed.
Example s1#=soundex ('MacKew')
s2#=soundex ('McQue')
if s1# <> s2# ! should sound alike
mem:msg='Does NOT sound alike'
else
mem:msg='Do sound alike'
.
Author Paul Giroux 01-Feb-89
BIX: pgiroux
CompuServe: 72007,3677
FidoNet: 1:167/106.0
------------------------------------------------------------------------------
**end**
soundex function (str)
str string(30)
str_i byte, dim (30), over (str)
sound string (5)
snd_i byte, dim (5), over (sound)
strlen long
! ABCDEFGHIJKLMNOPQRSTUVWXYZ
sndx string ('01230120022455012623010202')
sndx_i byte, dim (26), over (sndx)
code
sound = 'A0000' ! initialize return string
str = upper(str) ! convert to upper case
strlen# = len (clip(str))
snd_i[1] = str_i[1] ! assign first char to result
cnt#=2 ! initialize count
loop i# = 2 to strlen# ! loop for length of string
d# = str_i[i#] ! eliminate double letters
if d# = str_i[i#+1] ! such as tt, rr, ss..
cycle
.
k# = d# - 65 + 1 ! 65 = val ('A'); get
if (k# < 1) or (k# > 26) ! position in sndx array;
cycle ! check for bounds overflow
.
c# = sndx_i[k#] ! get element of sndx array
if c# <> 48 ! 48=val ('0')=don't care
snd_i[cnt#] = c# ! assign to result
cnt# += 1 ! inc count
.
if cnt# = 6 then break.; ! we want 5 chars in all
.
return (sound) ! return soundex string