{"name":"call","operator":null,"title":"call","type":"command","url":"https://community.bistudio.com/wiki/call","revid":373729,"updated":"2025-06-23T13:37:41Z","groups":["Program Flow"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.85"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.85"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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.\nSee Scheduler to learn more about how the code is executed and behaves.","syntaxes":[{"syntax":"call code","since":null,"effect":null,"exec":null,"params":[{"name":"code","type":"Code","optional":false,"default":null,"description":"compiled instructions\n\n> [!NOTE]\n> **Operation Flashpoint:** Operation Flashpoint takes String.\n\n> [!NOTE]\n> This way of calling has access to its parent scope's `_this`, as all it does is creating a scope.","types":["Code"],"since":null,"text":"code: Code - compiled instructions\n\n> [!NOTE]\n> **Operation Flashpoint:** Operation Flashpoint takes String.\n\n> [!NOTE]\n> This way of calling has access to its parent scope's `_this`, as all it does is creating a scope."}],"returns":{"type":"Anything","types":["Anything"],"description":"the last value given in the function is returned - see the topic Function for more information","text":"Anything - the last value given in the function is returned - see the topic Function for more information"},"form":"unary","operator":null,"left":null,"right":{"text":"code","types":["Code"]}},{"syntax":"args call code","since":null,"effect":null,"exec":null,"params":[{"name":"args","type":"Anything","optional":false,"default":null,"description":"arguments that are passed to the function in the `_this` variable.","types":["Anything"],"since":null,"text":"args: Anything - arguments that are passed to the function in the `_this` variable."},{"name":"code","type":"Code","optional":false,"default":null,"description":"compiled instructions\n\n> [!NOTE]\n> **Operation Flashpoint:** Operation Flashpoint takes String.","types":["Code"],"since":null,"text":"code: Code - compiled instructions\n\n> [!NOTE]\n> **Operation Flashpoint:** Operation Flashpoint takes String."}],"returns":{"type":"Anything","types":["Anything"],"description":"the last value given in the function is returned. See the topic Function for more information.","text":"Anything - the last value given in the function is returned. See the topic Function for more information."},"form":"binary","operator":null,"left":{"text":"args","types":["Anything"]},"right":{"text":"code","types":["Code"]}},{"syntax":"hashMapObj call [methodName, arguments]","since":"arma3 2.14","effect":null,"exec":null,"params":[{"name":"hashMapObj","type":"HashMap","optional":false,"default":null,"description":"the HashMap (not necessarily created through createHashMapObject) to call the method on","types":["HashMap"],"since":null,"text":"hashMapObj: HashMap - the HashMap (not necessarily created through createHashMapObject) to call the method on"},{"name":"methodName","type":"String","optional":false,"default":null,"description":"the name of the method to call (the method must be defined in *hashMapObj*; see createHashMapObject)","types":["String"],"since":null,"text":"methodName: String - the name of the method to call (the method must be defined in *hashMapObj*; see createHashMapObject)"},{"name":"arguments","type":"Anything","optional":true,"default":"parent scope's `_this`","description":"arguments passed to the method in the `_this` variable","types":["Anything"],"since":null,"text":"arguments: Anything - (Optional, default parent scope's `_this`) arguments passed to the method in the `_this` variable"}],"returns":{"type":"Anything","types":["Anything"],"description":"the value returned by the methodName method","text":"Anything - the value returned by the *methodName* method"},"form":"binary","operator":null,"left":{"text":"hashMapObj","types":["HashMap"]},"right":{"text":"[methodName, arguments]","types":["Array"]}}],"examples":[{"text":"```sqf\ncall { hint str 123; };\n```","code":["call { hint str 123; };"]},{"text":"```sqf\n123 call { hint str _this; };\n```","code":["123 call { hint str _this; };"]},{"text":"```sqf\n_sum = [1, 2] call { (_this select 0) + (_this select 1); };\nhint str _sum; // displays 3\n```","code":["_sum = [1, 2] call { (_this select 0) + (_this select 1); };\nhint str _sum; // displays 3"]},{"text":"```sqf\n123 call compile \"hint str _this;\";\n```","code":["123 call compile \"hint str _this;\";"]},{"text":"```sqf\n_result = 123 call compile preprocessFileLineNumbers \"myFile.sqf\";\n```","code":["_result = 123 call compile preprocessFileLineNumbers \"myFile.sqf\";"]},{"text":"```sqf\nprivate _hashMapObj = createHashMapObject [[\n    [\"MyMethod\", { systemChat (\"MyMethod arguments: \" + str _this); }]\n]];\n\n_hashMapObj call [\"MyMethod\", [\"Hello there\", player, 123]]; // hints 'MyMethod arguments: [\"Hello there\", player, 123]'\n```","code":["private _hashMapObj = createHashMapObject [[\n\t[\"MyMethod\", { systemChat (\"MyMethod arguments: \" + str _this); }]\n]];\n\n_hashMapObj call [\"MyMethod\", [\"Hello there\", player, 123]]; // hints 'MyMethod arguments: [\"Hello there\", player, 123]'"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["spawn","execVM","canSuspend","compile","compileScript","preprocessFile","remoteExec","remoteExecCall"],"notes":[{"user":"Leopard20","date":"2021-11-05T10:52:49Z","text":"Contrary to a widespread misconception in the community, call doesn't necessarily execute the code in the Unscheduled Environment. Call simply means: \"execute the code here\", just like how you execute a code using then (`if (true) then _code`) or do. Therefore it does not change the environment:\n\n| *call* executed in environment: | Resulting environment of the code: |\n|---|---|\n| Scheduled | Scheduled |\n| Unscheduled | Unscheduled |\n\nThis means that doing something like this (which is misused very often):\n\n```sqf\nprivate _handle = _params spawn MY_fnc_Function;\nwaitUntil { scriptDone _handle };\n```\n\nis not needed, because a lot of performance would be wasted compared to simply doing this:\n\n```sqf\n_params call MY_fnc_Function;\n```\n\nwhich 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.\n\nIf it is necessary to execute a code in the Unscheduled Environment, one can use isNil instead:\n\n```sqf\nisNil {_params call MY_fnc_Function}; // MY_fnc_Function is always executed unscheduled, regardless of the current environment\n```\n\nor if there are no parameters, one can simply do this:\n\n```sqf\nisNil MY_fnc_Function\n```"}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Program Flow","Introduced with Operation Flashpoint version 1.85","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}