There isn't such command in Scratch yet. However, it has already been suggested.
<stop script>[/blocks] stops the whole script, so...
- always works*:
<forever if>[/blocks] and <if>[/blocks].
- only works* when there is nothing under it:
<repeat( [/blocks] and <repeat until>[/blocks]
* "works" means "works like the Exit command".
Last edited by mathematics (2011-02-12 09:11:04)
Offline
mathematics wrote:
There isn't such command in Scratch yet. However, it has already been suggested.
<stop script>[/blocks] stops the whole script, so...
- always works*:
<forever if>[/blocks] and <if>[/blocks].
- only works* when there is nothing under it:
<repeat( [/blocks] and <repeat until>[/blocks]
* "works" means "works like the Exit command".
Thanks for referring to my suggestion. I would really like it to happen.
Offline
Thanks guys.
I knew about the Stop Script command. However, I can't use it in this case as I need to continue executing the the code after exiting the loop.
mathematics wrote:
There isn't such command in Scratch yet. However, it has already been suggested.
<stop script>[/blocks] stops the whole script, so...
- always works*:
<forever if>[/blocks] and <if>[/blocks].
- only works* when there is nothing under it:
<repeat( [/blocks] and <repeat until>[/blocks]
* "works" means "works like the Exit command".
I don't understand this. These blocks look confusing. Can you elaborate on that? Thanks.
Offline
Just add a:
<< <and> <( <{ break }> <=> 0 )> >>
and just set break to 1 to break the loop.
Offline
There's no way to exit the loop prematurely then...
Offline
There IS!
[set [stop] to (1)] < <repeat clause> and <(stop) = (0)> > if <premature exit clause> [set [stop] to (0)] else [set [stop] to (1)] [coding]
and something similar can be done for repeat ().
Last edited by Hardmath123 (2011-02-15 06:40:58)
Offline
Hardmath123 wrote:
There IS!
Code:
[set [stop] to (1)] < <repeat clause> and <(stop) = (0)> > if <premature exit clause> [set [stop] to (0)] else [set [stop] to (1)] [coding]and something similar can be done for repeat ().
That's what I said... or tried to say anyway.
Offline
However, I don't get what you guys are saying...
Offline
Basically make one of the conditions of the loop: Variable == 1
To break the loop, set Variable to 0.
Offline