"jump " function?

Hello, I remember from school a function that make a "jump" in the script . so it will go to the end of the loop , or to other part that I want.

I'm writing an example here, please fix me - loop() {

if (d==1) { Serial.println(" done"); go to end of loop } else { if (d==5) { Serial.println(" wait for it"); } if (d==9) Serial.println(" 1 more"); } } Serial.println(" it's almost over");

Serial.println(" the program is finish!"); //this where I want if d=1 to go , skip the rest of the script }

hope it's understood (what I wanted , and what I wrote)

thanks ,

"goto end of loop()" is called [b]return; [/b] ( valid for any function, not only loop() ) "goto end of for/while loop for the next round" is called [b]continue;[/b] "goto end of for/while loop and exit that loop" is called [b]break;[/b] ( also used in switch() { } )

this is what I meant Thanks a lot! and have a good day,


You would be better off using a ‘switch case’ statement for the code sample you have posted, give it a go it much better code than having break, continue and return buried in nested loops.

Duane B


my code is not that simple I just wrote it to explain what I need.

but O.K I'll try it also