How can the loop be stopped after one cycle?

ColRay:
I don't wanna be a real pain. How do I declare in the scope?

You can make global variables that all the code can see. They have universal scope to work between functions.