If you don't want to post the whole thing, and if you don't mind, you could send one of us the full script in a PM and we could probably find the error for you. The snippets aren't long enough.
On a second note, what you did post this time I still managed to compile, after creating all of the variables for it.