Skip to content
ffredyk edited this page Jul 23, 2026 · 1 revision

execVM

Category

Code Execution

Arity

UnaryexecVM <filePath>.

execVM <string>   // path to .sqf file

Description

Reads an .sqf file from disk, compiles it, and spawns it asynchronously on the current scheduler. Returns a ScriptHandle. This is the primary way to load and execute external script files.

How It Works

  1. Reads the file content from the given path.
  2. Compiles the source text into a Code value using the SQ# compiler.
  3. Spawns the compiled code as a new fiber on the current scheduler.
  4. Returns a ScriptHandle.

Equivalent to spawn compile (readFile _path) but as a single efficient operation.

Usage

Basic file execution

_handle = execVM "scripts\init.sqf";

With await

_handle = execVM "scripts\setup.sqf";
await _handle;
systemChat "Setup complete";

Loading multiple scripts

{
    _handles pushBack (execVM _x);
} forEach [
    "scripts\ai.sqf",
    "scripts\spawns.sqf",
    "scripts\loot.sqf"
];

Check if file exists before exec

if (!isNil { execVM "optional\addon.sqf" }) then {
    // file exists and was spawned
};

Thread Safety

Creates fiber on the current scheduler. File reading is synchronous (blocks briefly). The spawned code runs on the current scheduler.

See Also

  • spawn — spawn inline code
  • compile — compile string to code
  • call — synchronous execution
  • await — wait for handle

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally