execVM compiles and executes the corresponding sqf file and returns a handle to the executing script. Basically, it is a replacement in some cases of "exec".
But as said before, execVM looks for the file, loads it, compiles it and executes it. Conclusion: it is quite well suited for sqf scripts that have a "long" execution time with loops inside and Sleeps between loop iterations.
For a quick and fast calculation, on the other side, you have two options:
- If it is going to be used by several scripts, sqf and sqs, then create a function and call it (remember you cannot use sleeps there).
- If it is going to be used in the middle of the loop of an sqf script only, then just put your calculation code there, no need to create any function cause you are not going to get any performance improvement (remember that execVM compiles the code).
You may use also "spawn" command, which will execute the provided code in the same way execVM does, it will return also a script handler.
With returned script handlers (execVM and spawn), you may control the execution of the corresponding scripts from outside them checking their "script-finished" state with scriptDone command.
_handler = []execVM"myscript.sqf"
@scriptDone _handler
hint "Script done"