Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
void main(void) { run_GUI(); }void run_GUI(void) { do_something();//just rewrites a variable run_GUI(); }
void main(void){ run_test(5);}void run_test(int n){ print n; n = n - 1; if(n >= 0){ run_test(n); }}
void main(void){ run_test(32000);}
void main(void) { run_GUI(); rprintf("something"); }void run_GUI(void) { while(1) do_something(); }void do_something(void) { return;//what does this line do, exactly? }
int getOutOfHere = 0;void main(void) { run_GUI(); rprintf("something");}void run_GUI(void) { while(1){ if(getOutOfHere){ return; } do_something(); }}void do_something(void){ if( blah blah){ getOutOfHere = 1; } return;//what does this line do, exactly?}
Is there a 'forget all recursive history' line of code I can call, or do I have no choice but to finish a function to fully 'exit' it?(I'm guessing there isn't )
void main(void) { try { run_GUI(); } catch { } // continue on... }void run_GUI(void) { do_something();//just rewrites a variable run_GUI(); }void do_something(void) {... throw(1); }
But, If you would like to use a lot of memory and bring in lots of code, you could see if the GCC on the AVRs support structured exception handling Roll Eyes . Please forgive that I may not have the syntax correct as I have never used these on this platform nor used them period for over a decade...
Is there a 'forget all recursive history' line of code I can call, or do I have no choice but to finish a function to fully 'exit' it?
The best answer would be to set up a timer interrupt to call the function provided the function isnt already running (requiring a global boolean variable)
runner(){functionrunning = 1;functionrunning = myfunction(); // returns 0}int myfunction(){//your code herereturn 0;}interruptroutine(){ if (functionrunning == 0){ runner();}else{//do nothing}}
Code: [Select]void main(void) { run_GUI(); }void run_GUI(void) { do_something();//just rewrites a variable run_GUI(); }
void main(void) { for (;;) { run_GUI(); } }void run_GUI(void) { do_something();//just rewrites a variable }
void main(void) { //what ever function you'd use to print out_Int( get_Char() ); }//function that can get called recursively//returns an integerint get_Int(void) { //tmp space for user input char tmpIn[]; //sets the variable to the user input (wherever it comes from...) tmpIn = userInputFunction(); //The conditional to check if the userinput converts to an integer - atoi ASCII to integer if ( atoi(tmpIn) ) { //If the user input string converts, return the integer return atoi(tmpIn); } else { //If the user input string DOESN'T convert (returns a 0 value), return the value of the recursive return get_Int(); } }//function that would print out the integervoid out_Int(int theInt) { //print theInt }char[] userInputFunction(void) { //get user input }