sending flow back to the Loop()

It seems I can't just add the line somewhere in a function Loop; and have it go back to the Loop() routine?

I put a label first thing in the Loop() routine called StandbyLoop: but my reference to it later (goto StandbyLoop;) comp\iles with 'label used, but not defined' ???

You can use return; to exit a function. If that function is called from the loop() then you will return to loop.

Psuedo code follows

loop () {
myfunc();
}

void myfunc() {
if (something) {
do stuff
return // returns to loop
}

do other stuff stuff

// also returns to loop
}


Rob

That code won't compile. There is no setup() function, the variable something is not declared or valued anywhere, and the return statement is missing a ;.

Sorry, I should have made it clear that was psuedo code.

Here’s a modified version that does compile

void myfunc(void);

void setup (){};

void loop () {
   myfunc();
}

boolean something_is_true () {
  return true;
}

void myfunc(void) {
  if (something_is_true()) {
     //do stuff
     return;  // force a return to loop
  }
 

  //do other stuff stuff

  // return to loop automatically at end of the function
}

Rob

I may be misunderstanding your question, and my variation of the answer is "no".

If you are hoping to do something like:

**PSEUDOCODE** //   (PaulS, take note :-) )

 void loop() {
StandbyLoop:
  :  // various code
 GoFunction() ;
  :
}

Void GoFunction() {
  :  // more code
  if (something) goto StandbyLoop ;
  : other code 
}

then this is ILLEGAL. If it could be made to compile and run, it will eat up your stack (run out of RAM memory). Gotos can only be used inside the same function/procedure and not to jump around between them.

If you find you "need" this construct, then you have badly represented the external requirements in the logic of the program. Try and explain what you are doing that makes you want to "jump back to the begining".

You can code this kind of flow, similar to this

**PSEUDO CODE**
void loop() {
  : // Some code
  if ( GoFunction() ) {
    : // code that executes when not "jumping back"
  }
}

boolean GoFunction() {
  : // Code always done
  if ( ReasonToJumpBack ) return false ; signal to restart main loop
  : // code done if not jumping back
  return true ; // signal it went well, continue main loop
}