This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-15 22:01:22

Kowalskz
New Scratcher
Registered: 2010-11-20
Posts: 20

Exiting to the end of a loop

Hi,

1. I have a Repeat loop and the loop contains an IF statement. If the 'IF' condition is not true, I want to skip all the subsequent statements until the end of the loop and start the next iteration of the loop. Is it possible in Scratch?

2. Also, is it possible exit a repeat loop altogether if a certain condition is true, without executing the remaining lines of code.

Thanks.

Offline

 

#2 2012-01-16 03:07:14

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Exiting to the end of a loop

1) Put all the stuff you want to skip in the IF block.  smile
2) Yes, by using the repeat until instead of regular repeat. Have it say

Code:

repeat until <<(counter) < (value)> or <other condition>>

You will need a counter variable.

Offline

 

#3 2012-01-16 07:33:46

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Exiting to the end of a loop

[Removed by the Redundancy Police]

xD

Last edited by MoreGamesNow (2012-01-16 07:35:04)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer