return to a point in the loop

Hi
does anyone know how to return to a point in the loop. is it possible to have an if true else return to the beginning of the if or an if true skip to a point in the loop.
Any help is appreciated

That's a very broad question and not easy to give a simple answer.

A starting point might be to study "break", and "return" as well as "for" and "while".

I could probably help more if you describe the problem you want to solve.

...R

There exists this - http://www.cplusplus.com/reference/csetjmp/longjmp/ -
but it is considered a bad idea as you can corrupt the internal accounting of the program.

dansam8:
Hi
does anyone know how to return to a point in the loop. is it possible to have an if true else return to the beginning of the if or an if true skip to a point in the loop.
Any help is appreciated

This sounds like an attempt to create spaghetti code - what are you actually
trying to achieve - perhaps you are needing a continue, a state-machine, exception handling
or something else.

can you give an example of (pseudo) code what you want to do...

if true skip to a point in the loop

If you are looking to do something like this...

while (<some condition>) {
  if (myboolean) goto skip;
  // do some loop stuff
skip:
  // do myboolean stuff
}

Try this instead...

while (<some condition>) {
if (!myboolean)
 // do some loop stuff
else
  // do myboolean stuff
}

if true else return to the beginning of the if

If you are trying to do something like this...

loop:
if (myboolean)
  // do something
else
  goto loop;

Try this instead...

while (!myboolean);
// do something

Both of these of course assume that myboolean will get changed in an ISR somewhere.

dansam8:
does anyone know how to return to a point in the loop. is it possible to have an if true else return to the beginning of the if or an if true skip to a point in the loop.

Quite simply if you think you want to do this you are not coding correctly.
There will be a way to produce some structured code that does not need this concept.