Beruflich Dokumente
Kultur Dokumente
E I O U Y H W
F P V
G J K Q S X Z
T
N
not coded
coded as 1
coded as 2
coded as 3
coded as 4
coded as 5
coded as 6
Consonants after the initial letter are coded in the order they
occur:
HOLMES = H- 452, ADOMOMI = A-355
The code always uses initial letter plus three digits. Further
consonants in long names are ignored:
VONDERLEHR = V-536
Zeros are used to pad out shorter names:
BALL = B-400
SHAW = S-000
Double consonants are treated as one:
BALL = B-400
As are adjacent consonants from the same code group:
JACKSON = J-250
A consonant immediately following an initial letter from the
same code group is ignored:
SCANLON = S-545
Abbreviated prefixes should be spelt out in full:
ST JOHN = SAINTJOHN = S-532
Apostrophes and hyphens are ignored:
KING-SMITH = KINGSMITH = K-525
Consonants from the same code group separated by W or H are
treated as one:
BOOTH-DAVIS = B-312
The Soundex coding rules implemented
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=SOUNDEX.EXE is written in MicroSoft QuickBasic with TSR
capabilities added by the STAY-RES PLUS library from MICROHELP.
The code is supplied to enable you to write your own Soundex
calculator (e.g. for adding Soundex codes to data stotred in
ASCII files) in either QuickBasic or QBASIC (as supplied with
MSDOS v5.xx and v6.xx).
The QuickBasic code
-=-=-=-=-=-=-=-=-=DEFINT A-Z
'$INCLUDE: 'C:\AP\QB45\STAYRES4.DEC'
DECLARE SUB GETKEY (K$)
V$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N$ = "
"
CD$ = ""
CM$ = ""
K$ = ""
L$ = ""
P% = 0
V% = 0
Y% = 0
TRUE = -1
FALSE = 0
Kscan% = 31
Kshift% = 8
DIM A$(26)
DIM C$(26)
FOR X% = 1 TO 26
READ A$(X%), C$(X%)
NEXT
DATA A, ,B,1,C,2,D,3,E, ,F,1,G,2,H, ,I, ,J,2,K,2,L,4
DATA M,5,N,5,O, ,P,1,Q,2,R,6,S,2,T,3,U, ,V,1,W, ,X,2
DATA Y, ,Z,2
DIM P$(12)
CALL SrAutoScreenSave("", Ecode%)
SwapFile$ = "SOUNDEX"
CALL SrForceFile0
CALL SrSetDiskSwap(SwapFile$, Ecode%)
POPDOWN:
LOCATE , , 1
CALL SrPopDown(Kscan%, Kshift%, Ecode%)
START:
LOCATE , , 0
N$ = "
"
P% = 1
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
POKE 106, 0
COLOR 14, 1
LOCATE 11, 20
PRINT ""
LOCATE 12, 20
PRINT " Surname:
Soundex:
"
LOCATE 13, 20
PRINT ""
LOCATE 12, 31
COLOR 15, 10
PRINT N$;
LOCATE 12, 54
PRINT "
";
DO
CALL GETKEY(K$)
IF K$ = CHR$(13) AND P% > 1 THEN
GOTO SOUNDEX
END IF
IF K$ = CHR$(27) THEN
GOTO POPDOWN
END IF
IF K$ = CHR$(8) AND P% > 1 THEN
P% = P% - 1
MID$(N$, P%, 1) = " "
LOCATE 12, 31
PRINT N$;
END IF
V% = INSTR(V$, K$)
IF V% <> 0 THEN
MID$(N$, P%, 1) = K$
LOCATE 12, 31
PRINT N$;
P% = P% + 1
END IF
LOOP UNTIL P% > 12
SOUNDEX:
CD$ = LEFT$(N$, 1)
FOR Y% = 2 TO LEN(N$)
L$ = MID$(N$, Y%, 1)
IF INSTR("HW", L$) > 0 THEN L$ = ""
CD$ = CD$ + L$
NEXT
CM$ = LEFT$(N$, 1) + "-"
P$(1) = C$(INSTR(V$, LEFT$(N$, 1)))
FOR Y% = 2 TO LEN(CD$)
L$ = MID$(CD$, Y%, 1)
P$(Y%) = C$(INSTR(V$, L$))
IF P$(Y%) = P$(Y% - 1) THEN
L$ = "!"
END IF
IF INSTR(V$, L$) <> 0 THEN
CM$ = CM$ + C$(INSTR(V$, L$))
END IF
NEXT
IF LEN(CM$) < 5 THEN
FOR X% = 1 TO 5 - LEN(CM$)
CM$ = CM$ + "O"
NEXT
END IF
CM$ = LEFT$(CM$, 5)
LOCATE 12, 54
PRINT CM$;
CALL GETKEY(K$)
IF K$ = CHR$(27) THEN
GOTO POPDOWN
END IF
GOTO START
SUB GETKEY (K$) STATIC
K$ = ""
WHILE K$ = ""
K$ = UCASE$(INKEY$)
WEND
END SUB
Status of the program
-=-=-=-=-=-=-=-=-=-=Both the BASIC code and the compiled SOUNDEX.EXE are placed in
the public domain. You are free to distribute the BASIC code,
the compiled SOUNDEX.EXE, and any programs developed from them.
Mark Myatt
London 1995