djsfantasi
- Joined Apr 11, 2010
- 9,156
I just noticed the "goto" statement in yout if statement. We need to find a way to code that logic, so the "goto" is not needed. I'm of the camp that says goto is rarely, if not ever, needed. If it is used to pass control out of a code block with locally defined variables, yu are going to get memory corruption. I'd much rather use break to exit while and for loops and if I have to, define a boolean to indicate the break occurred and then goto the desired location... IF THATS THE ONLY WAY TO GET THE FLOW NEEDED. In your case, a band-aid approach would be to create another loop and when you execute the break command, execution would fall to the outer (new) loop end and it would repeat.
Oh, and I also just noticed your use of label: and its associated goto's. You are re-defining a string over and over, each time you goto label:. This is bound to cause memory problems. I'd move the definition of test_str to the beginning of the function, where it will only be executed once.
You may find this (click here->) library useful when debugging. You can keep track of free memory with debug statements (Serial.println)
Oh, and I also just noticed your use of label: and its associated goto's. You are re-defining a string over and over, each time you goto label:. This is bound to cause memory problems. I'd move the definition of test_str to the beginning of the function, where it will only be executed once.
You may find this (click here->) library useful when debugging. You can keep track of free memory with debug statements (Serial.println)