2017-09-28 20:59:35

I tried to ask this yesterday but nobody answered, probably because the links and the code were a mess. I coded everything again from zero, all in one bgt file, and included the text to be parsed in the RAR.

What I need this to do: Ask for filename to parse (in this case, spoiler.txt, included in the RAR) then a filename to save (this can be anything). It then will parse the txt, build string arrays with the fields and store those arrays on a single string inside a dictionary. This dictionary will then be serialized and saved. The script will then open the saved file, deserialize and reconstruct that array of string arrays. Finally, it will create an audio_form and fill a list with one item for each entry, which should account for 350 list items.

Now, I have absolutely no idea why this is returning Runtime Error, where did I mess the arrays?

The File: https://www.dropbox.com/s/fb30x4apnyuhz … r.rar?dl=0

Help me, dudes, you are my only hope to get this working!

2017-09-28 21:46:29

Replying from mobile, so can't look at the code, but it sounds like an index out of bounds error. I find that whenever I need to parse a file where I need something other than a simple for i in lines type situation, it's almost mandatory to check the length of the source array before advancing. If something happens such that the line count isn't exactly what you expect, you could crash with an index out of bounds error.
If this is what's happening, since you're loading cards, you probably want it to fail silently and keep whatever data was retrieved, so you'd want to get out of the loop/function if you hit the end of the array earlier than expected.
There are cases where this can get a bit ridiculous, where it's legal to end the file early and each line is something unique, in which case you'd need to check on every other line. It doesn't sound like this is quite that extreme, though.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2017-09-28 22:00:45

Dude, if you can take a look at it later I would be so grateful. I've read the code numerous times but I just can't find were's this out of bounds index.

2017-10-12 20:24:56

If you still need help with this...
A quick skimming of the code tells me to worry about this line:
form.add_list_item(deck, card_list[x][0]);
Although it looks like your code for loading cards always guarantees that the array at card_list[x] will not be empty, I'd check to be sure. if(card_list[x].is_empty()) alert("Malformed Card", "The card at index " + x + " has length 0.");

Anywhere that you reference a specific index by number, and there isn't a preceding line that guarantees that it's in bounds, it's a good idea to check explicitly.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.