Post by dkl on Oct 31, 2021 0:24:45 GMT -5
This seems to work well, but would really appreciate someone checking that it runs correctly!
Is there a limit to the number of times a variable can redimed in a programme? I wouldn't have thought so, but after clearing all variables/arrays/strings I get an error with the array that
loads the dictionary. It is a high value - dict$(280000), so I am wondering if its a bug or a memory problem. Any ideas?
loads the dictionary. It is a high value - dict$(280000), so I am wondering if its a bug or a memory problem. Any ideas?
Dim dict$(280000),letr$(30),Uword$(30),Uword2$(30)
Dim store4$(2000),store5$(2000),store6$(2000),store7$(2000),store8$(2000),store9$(2000),store10$(2000)
c = 1
wordCount = 279000'235886
'path$ = "C:\Users\kleth\Desktop\" 'add word.txt file path$ here
path$ = "L:\_New Projects\Anagrams\"
doc$ = "Collins Scrabble Words (2019).txt"
'doc$ = "words1.txt"
f$ = path$+doc$
'---------------------------------------------------------------------------GUI
'nomainwin
WindowWidth = 930
WindowHeight = 600
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
x=10:y = 80:w = 110:h = 400:xgap = w+20
ListboxColor$ = "lightgray"
listbox #1.4, store4$(), [EH], x+(xgap*0), y, w, h
listbox #1.5, store5$(), [EH], x+(xgap*1), y, w, h
listbox #1.6, store6$(), [EH], x+(xgap*2), y, w, h
listbox #1.7, store7$(), [EH], x+(xgap*3), y, w, h
listbox #1.8, store8$(), [EH], x+(xgap*4), y, w, h
listbox #1.9, store9$(), [EH], x+(xgap*5), y, w, h
listbox #1.10, store10$(), [EH], x+(xgap*6),y, w, h
button #1.ext, "Exit", [quit],UL,860, y-70, 35, 25
stylebits #1.tb1, _ES_CENTER, 0, 0, 0
textbox #1.in, x, y-60, 200, 25
stylebits #1.ok, _BS_DEFPUSHBUTTON, 0, 0, 0
button #1.ok, "OK", [getWord],UL, x+205, y-60, 30, 25
button #1.nt, "Next", [next],UL, x+245, y-60, 40, 25
statictext #1.ina, "Input User Word (Min 4 - Max 10 Letters)",10+(xgap*0),0,340,20
statictext #1.4a, "4 Letter Words",10+(xgap*0),y-20,120,20
statictext #1.5a, "5 Letter Words",10+(xgap*1),y-20,120,20
statictext #1.6a, "6 Letter Words",10+(xgap*2),y-20,120,20
statictext #1.7a, "7 Letter Words",10+(xgap*3),y-20,120,20
statictext #1.8a, "8 Letter Words",10+(xgap*4),y-20,120,20
statictext #1.9a, "9 Letter Words",10+(xgap*5),y-20,120,20
statictext #1.10a, "10 Letter Words",10+(xgap*6),y-20,120,20
y2 = 500
statictext #1.4b, "Word Count",10+(xgap*0),y2-20,120,20
statictext #1.5b, "Word Count",10+(xgap*1),y2-20,120,20
statictext #1.6b, "Word Count",10+(xgap*2),y2-20,120,20
statictext #1.7b, "Word Count",10+(xgap*3),y2-20,120,20
statictext #1.8b, "Word Count",10+(xgap*4),y2-20,120,20
statictext #1.9b, "Word Count",10+(xgap*5),y2-20,120,20
statictext #1.10b, "Word Count",10+(xgap*6),y2-20,120,20
textbox #1.4t, x+(xgap*0), 500, 30, 25
textbox #1.5t, x+(xgap*1), 500, 30, 25
textbox #1.6t, x+(xgap*2), 500, 30, 25
textbox #1.7t, x+(xgap*3), 500, 30, 25
textbox #1.8t, x+(xgap*4), 500, 30, 25
textbox #1.9t, x+(xgap*5), 500, 30, 25
textbox #1.10t, x+(xgap*6), 500, 30, 25
stylebits #1.inf, _ES_CENTER, 0, 0, 0
textbox #1.inf, x+350, y-80, 400, 25
TextboxColor$ = "green"
stylebits #1.sinf, _ES_CENTER, 0, 0, 0
textbox #1.sinf, x+350, y-50, 400, 25
BackgroundColor$ = "darkcyan"
[main_loop]
if op = 0 then open w$ for Window as #1:op = 1
#1, "font Georgia 10 bold"
'#1.ina,"!font Georgia 10 bold":#1.4a,"!font Georgia 10 bold":#1.5a,"!font Georgia 10 bold":#1.6a,"!font Georgia 10 bold"
'#1.7a,"!font Georgia 10 bold":#1.8a,"!font Georgia 10 bold":#1.9a,"!font Georgia 10 bold":#1.10a,"!font Georgia 10 bold"
'#1.ina,"!font Georgia 10 bold":#1.4b,"!font Georgia 10 bold":#1.5b,"!font Georgia 10 bold":#1.6b,"!font Georgia 10 bold"
'#1.7b,"!font Georgia 10 bold":#1.8b,"!font Georgia 10 bold":#1.9b,"!font Georgia 10 bold":#1.10b,"!font Georgia 10 bold"
'#1.in,"!font Georgia 10 bold":#1.4,"font Georgia 10 bold":#1.5,"font Georgia 10 bold":#1.6,"font Georgia 10 bold"
'#1.7,"font Georgia 10 bold":#1.8,"font Georgia 10 bold":#1.9,"font Georgia 10 bold":#1.10,"font Georgia 10 bold"
#1.in, "!setfocus"
#1.inf "!hide"
#1.sinf "!hide"
wait
'---------------------------------------------------------------------------
[loadData]
lnwd = len(Uword$) 'len of User word
Uword2$ = Uword$
open f$ for input as #rd
print "loading word file........"
#1.inf, "!show":#1.inf, "loading word file........................"
for rd = 1 to wordCount
line input #rd,data$:if len(data$) >= 4 and len(data$) <= lnwd then ct = ct +1:dict$(ct) = lower$(trim$(data$))
if data$ = "" then exit for
next rd
close #rd
print ct;" words loaded from ";wordCount;" words available"
#1.inf,"":#1.inf,ct;" words loaded from ";wordCount;" words available"
#1.sinf,"!show":#1.sinf,"Searching Wordlist..............."
[split] 'seperate letters in dictionary Word(dict$)
lnDct = len(dict$(c)) 'len of dictionary word
for a = 1 to lnDct
letr$(a) = mid$(dict$(c),a,1)
'print letr$(a)
next a
[srch] 'compare leters in Uword$ with dict$ word
for b = 1 to lnwd'Uword loop
pos = instr(Uword$,letr$(b)):if pos <> 0 then Lct = Lct + 1:Uword$ = mid$(Uword$,1,pos-1) + mid$(Uword$,pos+1,len(Uword$))':print Uword$, letr$(b)
'pos = instr(Uword$,letr$(b)):if pos <> 0 then Lct = Lct +1':print letr$(b)
next b
if Lct = lnDct then gosub [store]
Lct = 0:lnDct = 0
[nextWord]'this clears old info to search for next word in dict$ WORD LIST. It has nothing to do with restarting and searching a NEW word
redim letr$(30)
Uword$ = Uword2$ 'reinstate User word
c = c + 1:if c = ct then [end]
goto [split]
[end]
#1.sinf,"":#1.sinf,"!hide"':#1.inf,"":#1.inf,"!hide"
#1.4, "reload":#1.5, "reload":#1.6, "reload":#1.7, "reload":#1.8, "reload":#1.9, "reload":#1.10, "reload"
#1.4t, st4:#1.5t, st5:#1.6t, st6:#1.7t, st7:#1.8t, st8:#1.9t, st9:#1.10t, st10
print:print "4 letter words - ";st4-1:p = 0
for pr = 1 to st4
print store4$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "5 letter words - ";st5-1:p = 0
for pr = 1 to st5
print store5$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "6 letter words - ";st6-1:p = 0
for pr = 1 to st6
print store6$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "7 letter words - ";st7-1:p = 0
for pr = 1 to st7
print store7$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "8 letter words - ";st8-1:p = 0
for pr = 1 to st8
print store8$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "9 letter words - ";st9-1:p = 0
for pr = 1 to st9
print store9$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "10 letter words - ";st10-1:p = 0
for pr = 1 to st10
print store10$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
total = st4+st5+st6+st7+st8+st9+st10
print total;" words found in total"
#1.inf, "":#1.inf,total;" words found in total"
wait
[store]
if lnDct = 4 then store4$(st4) = dict$(c):st4 = st4 +1
if lnDct = 5 then store5$(st5) = dict$(c):st5 = st5 +1
if lnDct = 6 then store6$(st6) = dict$(c):st6 = st6 +1
if lnDct = 7 then store7$(st7) = dict$(c):st7 = st7 +1
if lnDct = 8 then store8$(st8) = dict$(c):st8 = st8 +1
if lnDct = 9 then store9$(st9) = dict$(c):st9 = st9 +1
if lnDct = 10 then store10$(st10) = dict$(c):st10 = st10 +1
return
[getWord]
#1.in,"!contents? Uword$"
Uword$ = lower$(trim$(Uword$))
Uword2$ = Uword$
lnwd = len(Uword$) 'len of User word
goto [loadData]
[next]
redim letr$(30):redim Uword$(30):redim Uword2$(30):redim dict$(280000)
redim store4$(2000):redim store5$(2000):redim store6$(2000):redim store7$(2000)
redim store8$(2000):redim store9$(2000):redim store10$(2000)
#1.4, "reload":#1.5, "reload":#1.6, "reload":#1.7, "reload":#1.8, "reload":#1.9, "reload":#1.10, "reload"
#1.4t, "":#1.5t, "":#1.6t, "":#1.7t, "":#1.8t, "":#1.9t, "":#1.10t, ""
st4 = 0:st5 = 0:st6 = 0:st7 = 0:st8 = 0:st9 = 0:st10 = 0
c = 0
#1.in,"":#1.in,"!setfocus"
goto [main_loop]
[quit]
close #1
end
This is the wordList I used @ boardgames.stackexchange.com/questions/38366/latest-collins-scrabble-words-list-in-text-file