Page tree
Skip to end of metadata
Go to start of metadata


Introduced in

Version:1.00

Description

Description:

Executes the passed code, and waits for it to finish.

The passed commands must be of type Code (enclosed in curly brackets) - to call a String (for example, as returned by format, loadFile, or preprocessFile), it must be converted using compile first.

The called code is executed on a lower scope than the calling code, and shares the variable space with the calling script (unlike spawn, which does not). For more information, see Scope.

The called code can contain wait commands (for example, sleep, while, waitUntil).

Syntax

Syntax:arguments call body
Parameters:
  • arguments: Any Value - Arguments passed to the function in the _this variable. To pass multiple values, use an array (optional).
  • body: Code - Code to execute.
Return Value:Anything - Result of the last command executed in the called code.

Alternative Syntax

Syntax:arguments call path (V3.8+)
Parameters:
  • arguments: Any Value - Arguments passed to the function in the _this variable. To pass multiple values, use an array (optional).
  • path: String - Path to the file to execute. Can be:
    • Relative to mission (starting with a folder or file name).
    • Relative to addon (starting with a backslash)
    • Absolute (starting with a drive letter).
Return Value:Anything - Result of the last command executed in the called code.

Examples

Examples:
// Simple call of passed code
call {tank1 setDamage 1}; 

// Calling a previously defined function
_cubed = {                // function definition    
  private ["_in","_out"]; // keep scope of variables used local
  _in = _this select 0;   // passed argument
  _out = _in * _in * _in; // function operation
  _out // returned value
}; 
_n = 3;
_n3 = [_n] call _cubed;  // calling function (_n3 will contain 27)

// Calling a formatted string
_v = 1;
call compile format ["var%1 = 9",_v]; var1 will contain 9

// Calling the result of loadFile
_fAdd = compile loadFile "add.sqf"
_result = [1,2] call _fAdd;  
_ret = call "sub\func.sqf"; // executes "func.sqf" in the mission \sub folder
_ret = call "C:\BI\Scripts\tst.sqf"; // executes "tst.sqf" in "C:\BI\Scripts\"

Additional Information

See also: spawn, compile, preprocessFile, Function
Multiplayer: 
Problems: 

Notes