PDA

View Full Version : Need help with ScriptTimeoutError



Dornkirk
October 25th, 2008, 12:29 AM
Hello everyone,

This is my first time at Kirupa's forum (been to the website, never visited the forum before), so I'm sorry if this question has been asked (I ran a search and didn't come up with anything).

Basically I'm building a Sudoku application right now, it's pretty lengthy running at around 1600 lines of code. This is because there are of course several techniques that are useful for finding out what the possible values are for a cell: simply run through all the cells in the column, the row, and the minigrid and delete duplicates from the possible values property of each cell, check each row, column, and minigrids for twins and triplets, look for numbers that are alone, etc. As a result of this I have one solver function which is called after the new puzzle is generated, this function calls all of these methods. Some of these methods are more efficient on memory than others, so I have them all nested in do while loops where the most efficient methods are on the top, these methods will keep getting checked as long as new values are found, if no new values are found it skips down to the next most efficient methods, etc.

I have this solver function in a try block, with the catch set to catch (e:ScriptTimeoutError). Unfortunately, it doesn't seem to be working. I'm wondering if anyone can help me out, all flash does is end up "Not Responding" and I have to end cmd-option-esc the program.

I decided instead of wrapping the try catch inside the solver function, which is what I initially had, I would create a new function to call the solver function and instead just try catch that:



try
{
Solve();
}
catch (e:ScriptTimeoutError)
{
solved = true;
changed = false;
forceQuit = true;
}

and inside the Solve function I nested everything in an if (!forceQuit) {}.

So I've never really had to use ScriptTimeoutError before, what am I doing wrong? Is my solve function just way too complicated? I decided to make this new function which has the try...catch call the Solve function just because that's what the Adobe help file similarly had.

Anyways any help you guys can give me would definitely be appreciated. Thanks.

wvxvw
October 25th, 2008, 08:30 AM
You're positively on the right track, but, it seems like you've forgotten to check for that forceQuit somewhere, so the code keeps executing in loops even after you set it to true.
What else you can do: execute blocks of solving functions on separate Timer updates. Every handler invoked by the timer update opens a new stack, thus starting to count the code execution time afresh. The same is true for ENTER_FRAME event.

Dornkirk
October 30th, 2008, 12:44 AM
I've gone through line after line trying new things out and I can't seem to stop flash player from dying like 1 times out of 10 when I run it.

Does anyone know of any better debugging utilities? I can't exactly know where things are going wrong because I have to cmd-opt-esc flash. Is there any way that I can have Flash generate a crash log or something? (I really don't know how to do this or if it sounds like something that's possible, I've never had to create a log before from a crashed program)

Thanks for any help.

Krilnon
October 30th, 2008, 12:51 AM
This doesn't directly address your question, but you can set the script timeout limit to something larger than 15 seconds in the document publish settings if you want.

Also, do you really have forceQuit == true; in your code, or was that a typo?

Dornkirk
October 30th, 2008, 01:14 AM
That was a typo, I fixed that days ago. I'll edit the post to reflect that.

wvxvw
October 30th, 2008, 05:30 AM
You have a debugger in Flash, hit Ctrl + Shift + Enter when you compile.
There's also a debugger in FlexBuilder, but it seems unlikely you can be unaware of that if you are using builder. There's also FDBplugin for FlashDevelop. However, the sort of script you want to debug will likely hang your system, so the debuggers will became useless... I'd try commenting out parts of the code to see what keeps the function from exiting the recursion loop.