You've really made things hard for yourself and us by not reading how to post here.
Post the entire code for just the program that's not working. Do not omit parts of the code. Post the circuit as is.
Do not post other versions of code that are working, that's really confusing and irrelevant, we now have almost no idea what's going on...
Post the entire error messages with copy+paste - never paraphrase them. Make sure the errors you post are from the exact version of the code you posted (you've clearly failed to keep track of things - how do you expect us to?)
But firstly I'd ask you go away and learn the difference between a function declaration, a function call and a variable. That alone may allow you to solve and progress this issue.