maruk 80 Posted September 3, 2007 ArmA 2 will be laregerly compatible with Armed Assault. To make porting of content from ArmA as simple as possible. Currently, one of the most important things is: * using of undefined variable in scripts (nil value) will be in ArmA 2 strictly reported as an error. All variables used in any scripts must be initialized before first use. Reference: community.bistudio.com Share this post Link to post Share on other sites
mrj-fin 0 Posted September 3, 2007 Nice to hear that means as the continuity is guarented and many mods team will stay loyal for this game. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted September 3, 2007 Out of curiosity, Is using testing isNil against a variable to determine if it exists or not still fair game? I would assume that it is, but it's better to ask. Share this post Link to post Share on other sites
Spooner 0 Posted September 3, 2007 Well, as this is the single thing that most often causes me bugs, specifically by mistyping a variable name and it just defaulting to nil, I'm really happy to have this appear in SQF, even if I have to wait for ArmA II. Many thanks! Any chance of getting this patched into ArmA, where use of a keyword in a script turned ON this functionality? This was how it was done in Perl: if "use strict" was in a script then Perl would raise an error on an unrecognised variable, the default behaviour would be to just assume that it was nil (or the equivalent in Perl). OK, not seriously expecting you to do this, but it would be great if you could. A question for clarification: If you private a variable, but don't assign to it, does it default to nil or would dereferencing such a variable also be an error? Share this post Link to post Share on other sites
UNN 0 Posted September 3, 2007 (edited) Out of curiosity, Is using testing isNil against a variable to determine if it exists or not still fair game? *I would assume that it is, but it's better to ask.Yeah, it is a little confusing. I'm assuming he means that commands that try and reference undeclared variables will now return an error, rather than returning the the variable type the command expected. For example: _IsAlive=Alive NOSUCHOBJECT; Hint Format ["Is Alive %1",_IsAlive]; At the moment the above code would not return an error and the hint would display the value bool. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
sbsmac 0 Posted September 3, 2007 (edited) ArmA 2 will be laregerly compatible with Armed Assault. This is very reassuring - I'd been wondering whether the effort I've been putting into scripting lately was going to be wasted but this says otherwise. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
Hoot1988 0 Posted September 3, 2007 on behalf of the community i must say thank you Maruk. was wondering when the compatibility with arma2 discussions would come up. Share this post Link to post Share on other sites
sickboy 13 Posted September 3, 2007 Great News and thanks for keeping us updated Maruk! Share this post Link to post Share on other sites
crashdome 3 Posted September 3, 2007 I second that comment! Share this post Link to post Share on other sites
bravo 6 0 Posted September 4, 2007 Very good news! Thank you Team! So all the work made or still to be made or even in development can be used in ARMA2. Go Team! Share this post Link to post Share on other sites
General Barron 0 Posted September 4, 2007 Thanks for the heads-up, however, I'm not sure exactly what the definition of "initialized" is here. Will there be new scripting commands to declare/initialize a variable? Or do you just have to store a value in a variable first, as in _variable = 1? I would assume the latter, but I just want to be 100% sure I understand. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted September 4, 2007 (edited) Private declares a variable, although there is no matching declaration for public variables. Edit: Although this is perfectly valid in arma: MyGlobalVariable = nil; I would also like clarification on what BIS is considering initalised however. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
benreeper 0 Posted September 5, 2007 I would think that you would have to give the variable a value before it can be used in any operation. --Ben Share this post Link to post Share on other sites
General Barron 0 Posted September 6, 2007 I think this should be made into a sticky. Share this post Link to post Share on other sites
leehunt27 1 Posted September 7, 2007 I second the good news here!  Figured as much but nice to know for sure that all the effort we are putting into learning Arma I won't be wasted.  Thanks  Share this post Link to post Share on other sites
VictorFarbau 0 Posted September 8, 2007 (edited) * using of undefined variable in scripts (nil value) will be in ArmA 2 strictly reported as an error. Excellent. So the parser reports an error if a variable has a value of NIL when being used in a statement. That means that this tedious search for variable typos in long scripts will be history Like "_startxposition" vs "_starxposition" and the ususal typos, especially in longer or complex scripts. Thanks, VictorFarbau Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
shiner 0 Posted September 8, 2007 (edited) So lets say I have the following code: call compile format["%1Status = east", _varTarget]; _varTarget could be any number of targets and the variable beings stored doesn't exist before this moment. Does this count as initialization for that variable variable? Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
benreeper 0 Posted September 9, 2007 I don't think so. I always declare them before I do that. --Ben Edit: I believe that is a valid declaration. Share this post Link to post Share on other sites
sbsmac 0 Posted September 16, 2007 (edited) So lets say I have the following code:call compile format["%1Status = east", _varTarget]; _varTarget could be any number of targets and the variable beings stored doesn't exist before this moment. Does this count as initialization for that variable variable? Looks fine to me as long as _varTarget is defined. Let's say it is set to "foo". Format creates the string "foo1Status=east". Compile turns that into a command:- foo1Status=east Call runs the command so you are effectively creating a new initialised variable. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
sbsmac 0 Posted September 16, 2007 (edited) Although this is perfectly valid in arma:Code Sample MyGlobalVariable = nil; 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... 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... //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]; 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. (1) Of course, 'database' is a loose term here - it is usually a table/linked-list/hash/binary-tree or other simple structure. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
ACF 0 Posted September 23, 2007 There was some suggestion somewhere that SQF format scripting is the way forward. Will ArmA 2 support SQS and SQF, or SQF only? Share this post Link to post Share on other sites
snkman 351 Posted October 9, 2007 I belive ArmA 2 will support like ArmA 1 bouth .sqs and .sqf there is no reason why BIS should drop .sqs Share this post Link to post Share on other sites
rrores 0 Posted December 18, 2007 (edited) Hi _func = { _return = nil; _return }; _var = [] call _func; if !(isNil "_var") then { ................... }; this gives error? Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
sickboy 13 Posted December 18, 2007 Sqf is imho indeed the way forward. It's structure is imho a lot better compared to sqs and the possibilities to precompile and call or spawn later is a huge plus also. I also believe in unification and generalization of code, so imho all should be coded in 1 language and not multiple. As SQF has it's advantages over SQS I drop SQS as a whole personally. I believe sqs will still be supported in ArmA2, but why would you use it is my question Share this post Link to post Share on other sites