_TITLE "Make a word list" 'for QB64 B+ 2019-06-15 DIM PetesSpeech$
, text$
, i
, k$
, outputFile$
' VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV name your output file here VVVVVVVVVVVVVVVVVVVVVVVVV
outputFile$ = "TestLoad.txt"
' default word data for testing
'PetesSpeech$ = "Interesting age we live in. We now have machines to access information with just a little more time than if we knew (learned) how to do something ourselves. It makes me wonder how often students use these device resources. I hope not to the point where, without a machine backing them up, they'd be nearly uneducated. I mean if a pilot had to land an airliner in the Hudson, I'd rather he know his job and fly the plane in than be Googling how to crash land it while it's going down. Sure, there's always been ways to game the system, frat notes, old tests, etc., but never as much as today. It's just a shame that making our devices smarter makes us go in the opposite direction. The proof of that is a person today is considered an idiot if they don't know how to 'Google' it. You'd think the pride would be in not having to 'Google' it, but no."
'PetesSpeech$ = PetesSpeech$ + "If this person doesn't return it's a pretty good bet he spent most of what could have been educational time on signing up for as many BASIC programming site as he could find, in hopes someone would post a working code example. Honestly, since coding isn't a core course, I wonder why anyone who would want to learn coding would try so hard not to learn how to code. In a weird way, that's similar to the pilot analogy, except there is a whole different set of consequences when it comes to the crash part."
'PetesSpeech$ = PetesSpeech$ + "OK, now that I Murphy lawed it, the OP can come back, post some code, get some help, become the next Steve on the forum, and tell me to go shove my CPU where the Sun Microsystems doesn't shine."
'
' VVVVVVVVVVVVVVVVVVVVVVV to test above for word list un comment next line VVVVVVVVVVVVVVVVVVVVV
'text$ = PetesSpeech$ '
'' VVVVVVVVVVVVVVVVVVVV paste in here your own text here and uncomment text$ VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
'text$ =
'VVVVVVVVVVVVVVVVVVVVVVV if you want to load text from a file, have file ready named Paste_Into_File.txt VVVVVVVVVVVVVVV
' start processing the text$
SpaceOut
CHR$(10) + CHR$(13) + ",.!?(){}[]-/_", text$
' SpaceOut replaces chars with a spaceSplit1000 text$, " ", wordlist() ' Split1000 replaces all double spaces to single if " " is delimiter
NoDupeStr wordlist() ' remove repeated words
DIM keepers
(LBOUND(wordlist
) TO UBOUND(wordlist
)) ' scanning the list decide what to keep or not PRINT " <<< press k to keep, spacebar to skip..." IF k$
= "k" THEN keepers
(i
) = -1 ELSE keepers
(i
) = 0
SUB SpaceOut
(Remove$
, source$
) ' replace undesirable chars with a space source$ = b$
'a() must be initialized as redim a(lb to ub)
SUB NoDupeStr
(a
() AS STRING) 'make all the items in the a array unique like a proper set m = lba
m = m + 1
t(lba) = a(m): ti = lba
u = -1
IF a
(i
) <> "" THEN 'get rid of blanks ti = ti + 1
t(ti) = a(i)
a(i) = t(i)
'notes: REDIM the array(0) to be loaded before calling Split '<<<<<<<<<<<<<<<<<<<<<<< IMPORTANT!!!!
' bplus modifications of Galleon fix of Bulrush Split reply #13
' http://xmaxw.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=1612.0
' this sub further developed and tested here: \test\Strings\Split test.bas
copy = mystr 'make copy since we are messing with mystr when the delimiter is a space
'special case if delim is space, probably want to remove all excess space
copy
= MID$(copy
, 1, p
- 1) + MID$(copy
, p
+ 1)
curpos = 1
arrpos = 0
dpos
= INSTR(curpos
, copy
, delim
) arr
(arrpos
) = MID$(copy
, curpos
, dpos
- curpos
) arrpos = arrpos + 1
curpos = dpos + LD
dpos
= INSTR(curpos
, copy
, delim
) arr
(arrpos
) = MID$(copy
, curpos
)