But why there is -1 in the end?
It's kinda a habit of mine.
I usually use the count result with selecting elements from an array and array element indexes beging from 0 and the count begins from 1 so the count will then always go one further than the array element indexes, and will then cause error to pop up.
If you change the
_i=0 to
_i=1 you wouldn't need that -1..
because I cant understand the difference between execVM and preprocessFile
execVM is used to execute sqf
script, preprocessFile is used to preprocess a
function.
Function is still the same as it was in OFP:R, sqf script is basically new version of the old sqs; it allows the same formatting as in the functions and is more efficient.
For some reason execVM requires a named scripthandle when used in the editor (triggers, waypoints, init fields, etc), in that example of mine I use the name
void (
void = this execVM "rearm.sqf")..
Check out
this tutorial about the basic sqf scripting, much better than me trying to explain it
.
It's for Arma 1 but all of it is still relevant in Arma 2.
Only one thing has changed and that is that first you have to declare (give some value to) all variables you will be using in the script.