(Redirected from Eng:Forever)

 Forever Category Control Type C

The Forever block is a Control block and a C block. Blocks held inside this block will be in a loop — just like the Repeat () block and the Repeat Until () block, except that the loop never ends (unless the stop sign is clicked, the Stop All block is activated, or the stop script block is activated within the loop). Due to this infinite loop, the block has no bump at the bottom; having a bump would be pointless, as the blocks below it would never be activated.

This block has a slight delay, so for optimum speed of execution, single frame block stacks should be used.

An example of the behavior of a forever loop

## Example Uses

The block is one of the most commonly used blocks in Scratch because there are a lot of cases when an infinite loop is needed. Some common uses are:

• Keeping a sprite at another's location
```forever
go to [Sprite1 v]```
• A music loop
```forever
play sound [Battle theme v] until done
```
```forever
repeat (12)
turn left (3) degrees
end
repeat (12)
turn right (3) degrees
```

## Workaround

Main article: List of Block Workarounds

This block can be replicated in two ways: With a boolean statement that will never be true, or through recursion.

With the boolean method, the Repeat Until () block is used, along with the boolean statement. There are many that will never be true, including:

```<[1] = [-1]>
<[a] = [b]>
<(timer) = [-1]>
<not <not <>>>
```

A full workaround:

```repeat until <[1] = [-1]>
. . .
```

One method that does not involve false boolean statements is tail recursion. Tail recursion can be created by a script broadcasting the broadcast needed to start it, thus repeatedly running the script:

```when I receive [Recursion v]
. . .
```

This has some benefits to making projects. For example, the script is helpful since it can be used to create fractals.

This also works:

```repeat ([10^ v] of (309))
. . .
end```

This requires an operator that reports "Infinity", like:

```([10^ v] of (309))
([e^ v] of (1000))
(join [Infinity] [])```

All of these will work in the last workaround.