---
name: "call"
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/call
revid: 373729
updated: 2025-06-23T13:37:41Z
---

# call

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

## Description

Adds given set of compiled instructions to the current stack and waits for it to finish and return, provides an option to pass arguments to the executed [Code](../topics/Code.md).
See [Scheduler](../topics/Scheduler.md) to learn more about how the code is executed and behaves.

## Syntax

### Syntax 1

```sqf
call code
```

**Parameters:**

- `code`: [Code](../topics/Code.md) - [compile](../commands/compile.md)d instructions

  > [!NOTE]
  > **Operation Flashpoint:** Operation Flashpoint takes [String](../topics/String.md).

  > [!NOTE]
  > This way of calling has access to its parent scope's `_this`, as all it does is creating a scope.

**Returns:** [Anything](../topics/Anything.md) - the last value given in the function is returned - see the topic Function for more information

### Syntax 2

```sqf
args call code
```

**Parameters:**

- `args`: [Anything](../topics/Anything.md) - arguments that are passed to the function in the `_this` variable.
- `code`: [Code](../topics/Code.md) - [compile](../commands/compile.md)d instructions

  > [!NOTE]
  > **Operation Flashpoint:** Operation Flashpoint takes [String](../topics/String.md).

**Returns:** [Anything](../topics/Anything.md) - the last value given in the function is returned. See the topic Function for more information.

### Syntax 3

*since arma3 2.14*

```sqf
hashMapObj call [methodName, arguments]
```

**Parameters:**

- `hashMapObj`: [HashMap](../topics/HashMap.md) - the HashMap (not necessarily created through [createHashMapObject](../commands/createHashMapObject.md)) to call the method on
- `methodName`: [String](../topics/String.md) - the name of the method to call (the method must be defined in *hashMapObj*; see [createHashMapObject](../commands/createHashMapObject.md))
- `arguments`: [Anything](../topics/Anything.md) - (Optional, default parent scope's `_this`) arguments passed to the method in the `_this` variable

**Returns:** [Anything](../topics/Anything.md) - the value returned by the *methodName* method

## Examples

### Example 1

```sqf
call { hint str 123; };
```

### Example 2

```sqf
123 call { hint str _this; };
```

### Example 3

```sqf
_sum = [1, 2] call { (_this select 0) + (_this select 1); };
hint str _sum; // displays 3
```

### Example 4

```sqf
123 call compile "hint str _this;";
```

### Example 5

```sqf
_result = 123 call compile preprocessFileLineNumbers "myFile.sqf";
```

### Example 6

```sqf
private _hashMapObj = createHashMapObject [[
    ["MyMethod", { systemChat ("MyMethod arguments: " + str _this); }]
]];

_hashMapObj call ["MyMethod", ["Hello there", player, 123]]; // hints 'MyMethod arguments: ["Hello there", player, 123]'
```

## See also

[spawn](../commands/spawn.md) · [execVM](../commands/execVM.md) · [canSuspend](../commands/canSuspend.md) · [compile](../commands/compile.md) · [compileScript](../commands/compileScript.md) · [preprocessFile](../commands/preprocessFile.md) · [remoteExec](../commands/remoteExec.md) · [remoteExecCall](../commands/remoteExecCall.md)

## Community notes

**Leopard20** — 2021-11-05

Contrary to a widespread misconception in the community, [call](../commands/call.md) doesn't necessarily execute the code in the [Unscheduled Environment](../topics/Scheduler.md#unscheduled_environment). [Call](../commands/call.md) simply means: "execute the code here", just like how you execute a code using [then](../commands/then.md) (`if (true) then _code`) or [do](../commands/do.md). Therefore it does not change the environment:

| *[call](../commands/call.md)* executed in environment: | Resulting environment of the code: |
|---|---|
| Scheduled | Scheduled |
| Unscheduled | Unscheduled |

This means that doing something like this (which is misused very often):

```sqf
private _handle = _params spawn MY_fnc_Function;
waitUntil { scriptDone _handle };
```

is not needed, because a lot of performance would be wasted compared to simply doing this:

```sqf
_params call MY_fnc_Function;
```

which does the exact same thing as the previous code, except no new *"scheduler thread"* is created and the function executes seamlessly, plus the added performance benefit as mentioned before.

If it is necessary to execute a code in the [Unscheduled Environment](../topics/Scheduler.md#unscheduled_environment), one can use [isNil](../commands/isNil.md) instead:

```sqf
isNil {_params call MY_fnc_Function}; // MY_fnc_Function is always executed unscheduled, regardless of the current environment
```

or if there are no parameters, one can simply do this:

```sqf
isNil MY_fnc_Function
```

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