While ()
while <> {
}:: #c3af00
Category Experimental (in 2.0), Control (in 3.0)
Type C

The while () block was a C block and an experimental block. Blocks held inside this block will loop until the specified boolean statement is false, in which case any code beneath the block will execute. Like most experimental counter blocks, it was a hidden block, meaning it could not be accessed via the block palette.

This block is still present in Scratch 3.0 as a hidden block, and is fully functional. The block was moved to the Control category, and had a loop arrow added to the end of the block.


Main article: List of Block Workarounds

This block's functionality can still be accessed with the following workaround:

repeat until <not<. . .:: grey>>
    . . .

Example Uses

Due to how similar this block is with the repeat until () block, the two blocks share many example uses:

  • Moving a sprite until its X or Y position is at a certain amount

while <not <(x position) = (100)>> {
    move (10) steps
}:: #c3af00
  • Having a sprite stick to the mouse until the mouse is not down

while <mouse down> {
    go to [mouse pointer v]
}:: #c3af00

reset timer
while <(timer) < (limit)> {
. . .:: grey
}:: #c3af00

Cookies help us deliver our services. By using our services, you agree to our use of cookies.