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

Introduced in




Compile and execute an SQF Syntax script. The script is compiled every time the command is executed (no pre-compilation or caching).

If no path is supplied with the script name, then the file is assumed to be in the mission folder. If the specified script is not found in there, other locations are searched, depending on the VBS version and current mode (editor, single-player or multiplayer). See Location for details.


Syntax:argument execVM filename
  • argument: Anything - Argument that is passed to the called script, which can read using the _this variable. If multiple arguments are required, then an array can be passed, with its elements being available as _this select 0, _this select 1, and so on.
  • filename: String - Path to script file.
Return Value:Script - Script handle, which can be used to determine (using scriptDone) when the called script finishes.


Content of file hello.sqf:
hint "Hello, world";No arguments passed, no handle used, when calling the script:
execVM "hello.sqf"  
Content of file countdown.sqf, which uses a passed argument:
_start = _this select 0;                // first element of passed array is read,for "_i" from _start to 0 step -1 do {  // and used as the loop start value
  player sidechat str _i;
  sleep 1;

"countdown.sqf" is called with an argument:
[3] execVM "countdown.sqf";             // 3 second countdown
player sidechat "script done";

Since the called script is running in parallel, and the calling script is not waiting for it to finish, the command that follows it is executed right away, before the called script has finished (the output would be script done, 3, 2, 1, 0).
To wait for the script to finish, use the handle with scriptDone:
_sqf = [5] execVM "countdown.sqf";     // retrieve the handle for the script
waitUntil {scriptDone _sqf};           // and check for it to be done
player sidechat "script done";         // only then continue with the next command

Now the "script done" message is shown after the countdown script finishes, and the output would be: 5, 4, 3, 2, 1, 0, script done.

Additional Information

See also: spawn, call, scriptDone, scriptName, delayCall, Script (File), SQF Syntax, exec