Page 1 of 1

Global Variables in Function & Parsing Large File

Posted: 26 Apr 2019, 12:31
by A_Birdi
Hello!
I'm currently trying to make a function within this script that generates an array of strings, but only with words within the character limit specified.

My issue lies in the while loop. None of the global variables are recognized, nor is the locally redefined variable Index.

Currently just debugging 'List of Strings' as 5 Length, between 1 ~ 10 chars.

Additionally, I'm hoping somebody might have insight to improving how the Dictionary.txt is parsed into an array. I thought FileRead + StrSplit might work, but I'm a bit lost to implementing it (or lack of trying). Currently, my dictionary contains over 270,000 lines of single words and takes approx. 7 seconds for me to write into the array this way.
Spoiler

Re: Global Variables in Function & Parsing Large File

Posted: 26 Apr 2019, 13:55
by Osprey
Your global variables aren't recognized in the While loop because you forgot to put global at the top of the gen_ListStr() function that it's in.

As for using FileRead + StrSplit(), try:

Code: Select all

FileRead, myFile, Dictionary.txt
myArray := StrSplit(myFile, "`n", " `t")	; Split at newline characters and omit spaces and tabs from the start and end

Re: Global Variables in Function & Parsing Large File  Topic is solved

Posted: 26 Apr 2019, 14:35
by A_Birdi
Edit: Fixed it.