I don't think that is a declaration - very much the reverse! Note the following is not based on any knowledge of ArmA internals but from experience with analoguous interpreted systems. It's possible BIS have a different implementation but I would be surprised if so...Although this is perfectly valid in arma:
Code Sample
MyGlobalVariable = nil;
The best way to think of 'definedness' of variables is to consider that they live in a database(1) where entries consist of name/value pairs.
When you create a new variable with "myVar=1" you are actually creating an entry in the database where the 'name' field is set to "myVar" and the 'value' field is set to 1. (There is probably a 'type' field in ArmA but this is irrelevant to this discussion.)
When you subsequently run "myVar=2", the existing entry is updated with a new value field.
Assigning a 'value' of 'nil' to a variable can be used to remove an entry from the database. Note that 'nil' is not really a value at all, it is simply a convenient syntax. So you should really think of "myVar=nil" as "Undefine myVar". Similarly the 'isNil' command is best thought of as a test to see if an entry for that variable exists in the database.
Another point, in contrast to 'nil', which means that a variable doesn't even exist, 'null' is a valid value and just means that the thing to which the variable refers doesn't exist.
So, I would expect the following behaviour...
The 'private' command is interesting since it implies that it is creating uninitialised variables. When I get some time on my gaming PC I'll have a quick check to see if those variables are created with a null value.Code://Define a variable myVar=1; //Now delete it again myVar=nil; //Testing for existence can be done with 'isnil' if (isNil "myVar") then { hint "no variable called myVar exists";} //This should throw an error in Arma2 since we've just //deleted the variable hint format ["myvar is %1",myVar];
(1) Of course, 'database' is a loose term here - it is usually a table/linked-list/hash/binary-tree or other simple structure.
HOME
Reply With Quote


