COG Keyword - goto

Continue the execution at the statement after the given label. Note that a return statement will not continue the execution at the statement after the goto statement; return is not affected by goto.

Syntax:

  goto Label;
  // ...
Label:
  // ...
  goto Label;

Example of using a goto as a replacement for break statement:

  for (i = 0; i < 3; i = i + 1)
  {
     if (j == 42)
     {
        goto AfterForLoop;
     }
  }
AfterForLoop:
  // This line is reached after "for" loop is done, or when j == 42.
  • Create:
This page was last modified 23:18, 25 August 2008.   This page has been accessed 333 times.