Message Boards Message Boards

0
|
4790 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

Goto doesn't work

Posted 9 years ago

Goto doesn't recognize the label:

For[j = 1, j <= 10, j++,
  For[i = 1, i <= 10, i++,
   If[i == 3 && j == 4, Goto["ab"]]
   ]];
Label["ab"];
Print[i, j]
POSTED BY: Al Guy
2 Replies
Posted 9 years ago

Thanks.

POSTED BY: Al Guy

As explained in Problem with Label in a Do loop you need to have Goto and Label inside the same CompoundExpression.

For your case each line is a separate one. Quick fix is to wrap them with ():

(
 For[j = 1, j <= 10, j++, 
    For[i = 1, i <= 10, i++, If[i == 3 && j == 4, Goto["ab"]]]];
 Label["ab"];
 Print[i, j]
)
POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract