---
name: "do"
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/do
revid: 311159
updated: 2022-05-11T13:17:42Z
---

# do

*Command · Program Flow · Arma 3 v0.50 · introduced in Operation Flashpoint v1.85*

## Description

Executes *code*. Used as part of a construct, such as [while](../commands/while.md), [with](../commands/with.md), [for](../commands/for.md) and [switch](../commands/switch.md). The *code* is always executed in [missionNamespace](../commands/missionNamespace.md) unless [do](../commands/do.md) is used with [with](../commands/with.md) as an argument.

## Syntax

```sqf
construct do code
```

**Parameters:**

- `construct`: [While Type](../topics/While_Type.md) ([while](../commands/while.md)), [With Type](../topics/With_Type.md) ([with](../commands/with.md)), [For Type](../topics/For_Type.md) ([for](../commands/for.md)), [Switch Type](../topics/Switch_Type.md) ([switch](../commands/switch.md))
- `code`: [Code](../topics/Code.md)

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

## Examples

### Example 1

```sqf
while { b > a } do
{
    a = a + 1;
};
```

### Example 2

```sqf
with uiNamespace do
{
    MyUIVar = MyUIVar + 5;
};
```

### Example 3

```sqf
for "_i" from 1 to 10 do
{
    systemChat str _i;
    sleep 0.5;
};
```

### Example 4

```sqf
switch (50) do
{
    case 25: { hint "25" };
    case 50: { hint "50" }; // hints "50"
    case 75: { hint "75" };
    default { hint "nope" };
};
```

## See also

[Control Structures](../topics/Control_Structures.md)

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