---
name: "then"
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/then
revid: 351752
updated: 2024-01-03T10:15:29Z
---

# then

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

## Description

Links an [If Type](../topics/If_Type.md) with [Code](../topics/Code.md) to be executed if said [If Type](../topics/If_Type.md)'s condition is [true](../commands/true.md); otherwise, "[else](../commands/else.md)" code is executed if provided.

The alternative syntax allows to set "[then](../commands/then.md)" code and "[else](../commands/else.md)" code in one array.

> [!NOTE]
> Variables declared inside *thenCode* are private to that code block - see [Variables#Local Variables Scope](../topics/Variables.md#local-variables-scope).

## Syntax

```sqf
ifType then thenCode
```

**Parameters:**

- `ifType`: [If Type](../topics/If_Type.md)
- `thenCode`: [Code](../topics/Code.md) or [Array](../topics/Array.md) of [Code](../topics/Code.md):
  - [Code](../topics/Code.md) - code block to execute if *ifType*'s condition is [true](../commands/true.md)
  - [Array](../topics/Array.md) of [Code](../topics/Code.md) - array of two [Code](../topics/Code.md) elements in format [thenCode, elseCode]; see [#Example 3](../commands/then.md#example-3)

**Returns:** [Anything](../topics/Anything.md) - result of the executed code

## Examples

### Example 1

```sqf
if (a > b) then { hint "a is greater than b!"; };
```

### Example 2

```sqf
private _c = 0;
if (_a > _b) then
{
    _c = 1;
}
else
{
    _c = 2;
};
```

### Example 3

```sqf
if (alive player) then [{ hint "player is alive"; }, { hint "player is dead"; }];
```

### Example 4

```sqf
private _value = if (alive player) then { 1 } else { 0 };
```

## See also

[Control Structures](../topics/Control_Structures.md) · [if](../commands/if.md) · [else](../commands/else.md)

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