|This article or section documents a feature not included in the current version of Scratch (2.0). It is only useful from a historical perspective. For information on the feature that replaced this one, see Stop () (block).|
The Stop Script block was a Control block and a Cap block. The block would deactivate its script, stopping it completely. This block worked similar to the Stop All block, except that itwas confined to its script and did not deactivate all scripts in the project.
Before version 1.2, the block was a stack block.
- Main article: List of Block Workarounds
The "Stop Script" was most often used to stop loops (especially "forever" and "forever if" loops). A common work around is to use a "Repeat Until" loop instead.
repeat until <condition that should stop script> . . . end
However, such a work around is not perfect. The primary advantage of the "Stop Script" is its ability to be used throughout the loop. For loops that are lengthy, one often wants to stop the script as quickly as possible, rather than waiting for the script to loop back through the conditional. This is easily done with the "Stop Script" block within an If () Then (block). For instance, the following script has a faster "reaction time" to an event that demands the script be stopped than the one above.
forever . . . if <I should stop> stop script end . . . if <I should stop> stop script end
The following workaround pauses the script at one point forever, rather than stopping the script, but can still be used to prevent code from being activated.
when gf clicked . . . wait until < = [-1]> // the condition will never be met, thus making the script wait forever
As this block will stop its script, it is widely used when an action performed by a script must cease. Some common uses:
- Disabling controls
forever if <(ammunition) < > set [active v] to  stop script else set [active v] to  end
- Only performing an action once, and then stopping
forever if <(loss) = > broadcast [failure v] stop script
- Depending on a variable, if an action is performed or the script canceled
when I receive [Show v] switch to costume [costume1 v] if <(allow) = > go to x: (0) y: (0) else stop script end broadcast [Ready! v]