QB / QB64 Discussion Forum     RULES     Other Subforums, Links and Downloads    Index of Threads

 

 Return to Index  

SOUNDEX.BAS -- generate DICT2.DAT from DICT.DAT

September 7 2007 at 3:45 PM
qbguy  (no login)


Response to Spell Check Program

 

OPEN "DICT.DAT" FOR INPUT AS #1
OPEN "DICT2.DAT" FOR OUTPUT AS #2
WHILE NOT (EOF(1))
soundex$=""
INPUT #1, search$
search$ = LTRIM$(RTRIM$(UCASE$(search$)))
firstletter$ = LEFT$(search$, 1)
search$ = RIGHT$(search$, LEN(search$) - 1)
FOR i = 1 TO LEN(search$)
c$ = MID$(search$, i, 1)
SELECT CASE c$
CASE "B", "F", "P", "V"
soundex$ = soundex$ + "1"
CASE "C", "G", "J", "K", "Q", "S", "X", "Z"
soundex$ = soundex$ + "2"
CASE "D", "T"
soundex$ = soundex$ + "3"
CASE "L"
soundex$ = soundex$ + "4"
CASE "M", "N"
soundex$ = soundex$ + "5"
CASE "R"
soundex$ = soundex$ + "6"
END SELECT
NEXT
FOR i = 2 TO LEN(soundex$)
IF MID$(soundex$, i, 1) = MID$(soundex$, i - 1, 1) THEN
soundex$ = LEFT$(soundex$, i - 1) + MID$(soundex$, i + 1)
END IF
NEXT i
soundex$ = LEFT$(soundex$ + "000", 3)
soundex$ = firstletter$ + soundex$
PRINT #2, soundex$
WEND
END

 
 Respond to this message   
Response TitleAuthorDate
 SOUNDEX.BAS -- version 2
Page 1 2 3 4 59
qbguySep 8, 2007
 SOUNDEX.BAS -- Version 3
Page 1 2 3 4 59
qbguySep 8, 2007
 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement