Wordzie

Wordzie loads a file with words and helps in query to match words with an unknown set of letters replaced with a period ‘.’

'ab.de..
'h.j.l.
'no..r.t
'u.w...

DIM g$(255)

DIM fil$(255)
DIM a$(255)

all = 0: al = 0
SHELL "dir/b *.txt > dict.dat"
OPEN "dict.dat" FOR INPUT AS #1
c = 0
DO
    c = c + 1
    INPUT #1, a$(c)

LOOP UNTIL EOF(1)
CLOSE #1
f = c
c = 0
total = 0
found = 0
'INPUT "Use words.dat file?", yorn$
'IF LCASE$(yorn$) = "y" THEN total = 1
'OPEN "words.dat" FOR INPUT AS #3
'DO
'IF NOT (EOF(3)) AND total > 0 THEN INPUT #3, fil$(total): total = total + 1
'LOOP UNTIL EOF(3) OR total = 0
'CLOSE #3
'DO
'   IF total <> 0 THEN fill = fill + 1
DO


    CLS
    COLOR 5, 1
    PRINT "::  Wordzie by Page Telegram, (C) 2018, pagetelegram.com V3"
    COLOR 7, 0
    k = 0
    PRINT "Pick a database (1-UP, 2-DN) *-search all"
    IF c > 0 THEN LOCATE 3, 1: PRINT a$(c)
    IF all <> 1 THEN
        DO
            SELECT CASE INKEY$
                CASE "1": LOCATE 3, 1: IF c > 1 THEN c = c - 1: PRINT "UP: "; a$(c)
                CASE "2": LOCATE 3, 1: IF c < f THEN c = c + 1: PRINT "DN: "; a$(c)
                CASE "*": all = 1: k = 1
                CASE CHR$(27): SYSTEM
                CASE CHR$(32), CHR$(13): k = 1
            END SELECT
        LOOP UNTIL k = 1
    END IF
    IF all = 1 THEN c = c + 1
    dbs$ = a$(c)

    PRINT "Use '.' to indicate missing letter. Press [SPACE] to see seek position."
    IF al <> 1 AND total = 0 THEN INPUT "Word Search:", fnd$
    '  IF total > 0 THEN fnd$ = fil$(fill)
    IF al = 1 THEN PRINT "Word Search:"; fnd$

    IF all = 1 THEN al = 1
    fnds$ = LCASE$(fnd$)

    OPEN dbs$ FOR INPUT AS #2
    SHELL "echo " + dbs$ + " >> finds.dat"
    IF all <> 1 THEN c = 0
    tlc = 0
    DO
        IF NOT (EOF(2)) THEN INPUT #2, wrd$
        wrds$ = RTRIM$(LTRIM$(LCASE$(wrd$)))
        IF LEN(wrds$) = LEN(fnds$) THEN
            LOCATE 7, 30: PRINT found
            'LOCATE 7, 1: PRINT wrds$; "                      "
            FOR i = 1 TO LEN(fnds$)
                IF MID$(fnds$, i, 1) = "." THEN fund$ = fund$ + MID$(wrds$, i, 1)

                IF MID$(wrds$, i, 1) = MID$(fnds$, i, 1) THEN
                    fund$ = fund$ + MID$(wrds$, i, 1)
                    'LOCATE 6, 1: PRINT fund$
                END IF
                'END IF
            NEXT i
            IF LEN(fnds$) <= LEN(wrds$) THEN
                IF fund$ = wrds$ THEN
                    tlc = tlc + 1: g$(tlc) = fund$: 'LOCATE 9, 1: PRINT fund$; " - "
                    '    fund$ = ""
                    PRINT "*";
                    found = found + 1
                END IF
            END IF
            fund$ = ""
        END IF
        SELECT CASE INKEY$
            CASE CHR$(27): qt = 1
            CASE CHR$(32): LOCATE 7, 1: PRINT wrds$; "               "
        END SELECT
    LOOP UNTIL EOF(2) OR qt = 1
    CLOSE #2
    PRINT "Matches:"
    FOR i = 1 TO tlc
        PRINT g$(i); " - ";
        SHELL "echo " + g$(i) + " >> finds.dat"
    NEXT i
    PRINT "Written in tribute to Andrey:"
    print "http://missingandreyprice.com"
    PRINT
    PRINT "Press any key to continue..."
    SLEEP
LOOP UNTIL qt = 1 OR c >= f
'LOOP UNTIL fill = total OR qt = 1