---
name: "breakOut"
type: command
status: ok
groups: ["Program Flow"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/breakOut
revid: 369282
updated: 2024-09-03T18:42:47Z
---

# breakOut

*Command · Program Flow · Arma 3 v0.50 · introduced in Armed Assault v1.00*

## Description

Breaks out of the [scope](../topics/Variables.md#scopes) with given **name**.
- An unknown [scopeName](../commands/scopeName.md) name will cause the script error `Generic error in expression`
- If multiple scopes with the same **name** exist, the command will break out the nearest scope. See [#Example 3](../commands/breakOut.md#example-3).

## Syntax

### Syntax 1

```sqf
breakOut name
```

**Parameters:**

- `name`: [String](../topics/String.md) - name of the scope which was previously set with [scopeName](../commands/scopeName.md). `""` will exit the current scope (see also [exitWith](../commands/exitWith.md))

**Returns:** [Nothing](../topics/Nothing.md)

### Syntax 2

*since arma3 1.48*

```sqf
value breakOut name
```

**Parameters:**

- `value`: [Anything](../topics/Anything.md) - a value to return
- `name`: [String](../topics/String.md) - name of the scope which was previously set with [scopeName](../commands/scopeName.md). `""` will exit the current scope (see also [exitWith](../commands/exitWith.md))

**Returns:** [Anything](../topics/Anything.md) - will return **value**

## Examples

### Example 1

```sqf
scopeName "main";
while { true } do {
    scopeName "loop1";
    while {true} do {
        scopeName "loop2";
        if (condition1) then {breakTo "main"}; // Breaks all scopes and return to "main"
        if (condition2) then {breakOut "loop2"}; // Breaks scope named "loop2"
        sleep 1;
    };
    sleep 1;
};
```

### Example 2

```sqf
call {
    scopeName "main";
    call {
        123 breakOut "main"
    };
    345
}; // call returns 123
```

### Example 3

```sqf
call {
    scopeName "Main"; // Parent Main
    call {
        scopeName "Main"; // Child Main
        "String" breakOut "Main"; // Will break out of child main and return "String" to parent main
    };
};
```

## See also

[scopeName](../commands/scopeName.md) · [breakTo](../commands/breakTo.md) · [exitWith](../commands/exitWith.md)

<sub>Source: [BI Community Wiki — breakOut](https://community.bistudio.com/wiki/breakOut) (revision 369282).</sub>
