benreeper 0 Posted December 19, 2007 SQS makes for ugly, hard to follow, compromised code. SQF is also easier to use and more closely resembles what you may be used to if you used other languages. To me, it feels as if my Arma projects run smoother that my OFP ones. --Ben Share this post Link to post Share on other sites
snkman 351 Posted January 23, 2008 (edited) Hi_func = { _return = nil; _return }; _var = [] call _func; if !(isNil "_var") then { ................... }; this gives error? Well i understood it this way: You have to initialize every variable bevore first use so: WORKS: _number = 0; if (number == 0) then {hint "Zero"}; DIDN'T WORK: Becouse the variable has to be initialized BEVORE then {}; if (alive player) then {_number = 0}; if (number == 0) then {hint "Zero"}; But you still can use "isNil" becouse isNil do only check if the variable exist, and if not then it will be created. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
rrores 0 Posted January 24, 2008 (edited) DIDN'T WORK:Becouse the variable has to be initialized BEVORE then {}; if (alive player) then {_number = 0}; if (number == 0) then {hint "Zero"}; (thanks to respond) that does not work either in arma1. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
sickboy 13 Posted January 24, 2008 (edited) Basicly it just comes down to this: You must first initialize (set variable Type) a variable before you use it: Good: _var1 = 0; player globalChat format ["Test: %1", _var1]; Bad: player globalChat format ["Test: %1", _var1]; This code in ArmA would make player globalChat sth like "Test: SCALAR BOOL ARRAY STRING ....." The same code in ArmA2 will report an error, because _var1 was not initialized before. Good if (isNil "GlobalVar") then { GlobalVar = "" }; player globalChat format ["%1", GlobalVar]; Bad player globalChat format ["%1", GlobalVar]; This code in ArmA would make player globalChat sth like "SCALAR BOOL ARRAY STRING ....." The same code in ArmA2 will report an error, because GlobalVar was not initialized before Hi _func = { _return = nil; _return }; _var = [] call _func; if !(isNil "_var") then { ................... }; this gives error? I think this will work just fine. _var = nil destroys a variable if it existed, but doesnt create it if it didn't before. isNil "_var" should be a valid test Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
baddo 0 Posted January 24, 2008 (edited) DIDN'T WORK:Becouse the variable has to be initialized BEVORE then {}; if (alive player) then {_number = 0}; if (number == 0) then {hint "Zero"}; (thanks to respond) that does not work either in arma1. There is a typo isn't there. And it is intentionally done wrong (not the typo but the logic) to show you what doesn't work. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
rrores 0 Posted January 25, 2008 (edited) if (alive player) then {_number = 0}; if (_number == 0) then {hint "Zero"}; //ERROR IN ARMA1 ALSO IN ARMA2: single I want to know if the functions return null values thanks Edited April 14, 2009 by W0lle Share this post Link to post Share on other sites
dr_eyeball 16 Posted January 25, 2008 It would have been nice to see ArmA 1 with a command line parameter for developers to turn on this new "nil variable checking" already. It would allow ArmA 1 scripts to be properly tested for easier porting to ArmA 2, in anticipation of it's release. - It would already be very useful for debugging now. - It seems like a fairly simple change to implement. - By making it a exe param, it wouldn't interfere with existing mission scripts. Share this post Link to post Share on other sites
benreeper 0 Posted January 25, 2008 I'm pretty sure that everything from Arma will work in Arma2 so it shouldn't be the problem that we have now with OFP to Arma. There are many of us here creating Arma mods that can be ready on Day 1 of Arma2, if all goes according to plans. --Ben Share this post Link to post Share on other sites
snkman 351 Posted January 26, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (alive player) then {_number = 0}; if (_number == 0) then {hint "Zero"}; //ERROR IN ARMA1 ALSO IN ARMA2: single I want to know if the functions return null values thanks Yes becouse the variable was not initialized bevore the then {_number = 0}; Here is whats written in the biki about it: Quote[/b] ]If a local variable is initialized within a Control Structures (i.e. if, for, switch, while) its scope will stay within this structure (i.e. outside of the structure it will still be seen as undefined). This does not apply to global or public variables. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (alive player) then {_living=true}; hint format["%1",_living]; Returns "scalar bool array string 0xe0ffffef", since the local variable was not initialized before being used within a control structure. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dead=true; if (alive player) then {_dead=false}; hint format["%1",_dead]; Returns "false", since the variable was initialized before the if...then. EDIT: 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. So this will reported as an error! Share this post Link to post Share on other sites
baddo 0 Posted January 26, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (alive player) then {_number = 0}; if (_number == 0) then {hint "Zero"}; Â //ERROR IN ARMA1 ALSO IN ARMA2: Â single I want to know if the functions return null values thanks The logic of that code is wrong and there is no reason to change it to be right in ArmA 2. It is right that it doesn't work. Familiarize yourself with the programming concept "scope". Share this post Link to post Share on other sites
rrores 0 Posted January 26, 2008 EDIT: 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.So this will reported as an error! In ARMA1 also is ERROR. Share this post Link to post Share on other sites
Guest Posted July 26, 2008 Just to get a clear answer, due to the fact ive heard various rumors that Arma2 will not support it.. Will Arma2 support .Sqs block form code? Or only .sqf? Share this post Link to post Share on other sites
Guest Posted July 26, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (alive player) then {_number = 0}; if (_number == 0) then {hint "Zero"}; //ERROR IN ARMA1 ALSO IN ARMA2: single I want to know if the functions return null values thanks The logic of that code is wrong and there is no reason to change it to be right in ArmA 2. It is right that it doesn't work. Familiarize yourself with the programming concept "scope". it can work maybe it depends on usage : _ArtyGroup is undefined before these lines ;get proper arty crews from the clan number ;this is for getting correct crew names to join garrison units to for manning taken over arty pieces ?(_ClanNumber == 1):_ArtyGroup = VallonArtyCrew ?(_ClanNumber == 2):_ArtyGroup = ErudinArtyCrew ?(_ClanNumber == 5):_ArtyGroup = PovarArtyCrew ?(_ClanNumber == 7):_ArtyGroup = KaranaArtyCrew ?(_ClanNumber == 10):_ArtyGroup = RallosArtyCrew ?(_ClanNumber == 12):_ArtyGroup = TunareArtyCrew ;now leaving Rohan arty as a possibility, for Rohan taking over a town, this arty group is initiated at mission start as well ?(_ClanNumber == 14):_ArtyGroup = RohanArtyCrew ?(_ClanNumber == 3):_ArtyGroup = OgokkArtyCrew ?(_ClanNumber == 4):_ArtyGroup = MorkanArtyCrew ?(_ClanNumber == 6):_ArtyGroup = RatheArtyCrew ?(_ClanNumber == 8):_ArtyGroup = MarrArtyCrew ?(_ClanNumber == 9):_ArtyGroup = FelwitheArtyCrew ?(_ClanNumber == 11):_ArtyGroup = DruzzleArtyCrew ?(_ClanNumber == 13):_ArtyGroup = ThuragArtyCrew works fine, no errors When _ArtyGroup is checked, it always returns the proper global, no errors Now in a case where one of these lines did not execute to initialize _ArtyGroup, of course it would then fail. My understanding, is, either way, in this case, Arma2 will not support this, in my case, _ArtyGroup would have to be initialized before hand, and equal "something" before it could be used in the "then" part of an "if Then" statement. That kinda suks lol, because many of my scripts initialize locals thru if/then statements, and initializing them before hand will certainly add quite a bit of length to the initial parts of the scripts, but o well- it can be done Share this post Link to post Share on other sites
maruk 80 Posted April 11, 2009 Updated info over at Biki. About SQS: despite there are more advanced ways to script in ARMA 2 it will be still fully supported. Share this post Link to post Share on other sites
SaOk 112 Posted April 11, 2009 That is very nice. My all scripts in ArmA are still SQS because its simple, stable and I havent found any restrictions from it yet. Share this post Link to post Share on other sites
UNN 0 Posted April 12, 2009 in ArmA 2 namespaces will be introduced for user scripts and variables. There are many low level reasons to do this and most of the content will be not be affected by this in any negative way. However, in order to be prepared, it is very important to separate UI related scripts and code as much as possible and not simply share global variables between UI and missions as UI namespace needs to be handled differently. Any ideas what this means exactly. Will we still be able to interact with our own dialogs and scripts/objects running in game, in real time? Share this post Link to post Share on other sites
schaefsky 0 Posted April 14, 2009 Any ideas what this means exactly. Will we still be able to interact with our own dialogs and scripts/objects running in game, in real time? As far I understand it, short answer "yes". Considering your scripting work so far I assume you are familiar with the general concept of namespaces in programming. Now it seems that you will no longer be able to directly manipulate global variables in your UI scripts from mission (/addon?) scripts and vice versa. I suspect you would have to do something like let's say invoke a UI function with parameters you would like to have manipulated, this UI script would then be able to manipulate UI global variables. For example: Let SCH_GLOBAL_STRING be a global variable in UI namespace. Now invoking the follwing command from mission namespace would not work SCH_GLOBAL_STRING = "Some text" Now let "setText.sqf" be the following UI script: SCH_GLOBAL_STRING = _this You could then manipulate UI namespace variable with "Some text" call compile loadFile "setText.sqf" I could be completly wrong here, of course :cool: If I am not, I hope there will be a more elegant way to do this (if not, you will probably be able to work one out yourself) Share this post Link to post Share on other sites
Rommel 2 Posted April 14, 2009 Any official word on what this namespaces will actually entail; any chance BIS could ease our minds and give us a small example? Come on Ondrej! :P Share this post Link to post Share on other sites
PhilippRauch 0 Posted April 14, 2009 Yes, please my Javelin uses loads of Dialog/UI stuff... Share this post Link to post Share on other sites
dr_eyeball 16 Posted April 14, 2009 I'm guessing the UI namespace relates to the UI event handlers mainly, which are strings. (eg: MouseButtonDown, LBListSelChanged, Action, etc). But I'm guessing if you execute a script from those EH's, then those scripts will still have access to global variables, so long as they are not passed in as parameters, so you would simply need to move your processing logic into there. This would then encourage you to use the control which is already passed via the parameters too. Maybe they are expanding the ability to use nested dialogs or are providing access to certain Arma dialog's (eg: main menu(/action menu), scoreboard, etc) Share this post Link to post Share on other sites
alef 0 Posted April 15, 2009 in order to maintain smooth frame rate in real-time content, time limit for all scripts in each frame is enforced by the engine in ArmA 2. Generally speaking, in case of more demanding scripts, be prepared that their result may come way later and also there probably can suffer from significant latency. It is under evaluation if and how possibly allow user scripts to change how much time they may take from the CPU in every frame. It could be possible to have more info about this, thanks. If I run a "more demanding script", should I expect a frame change between statements, like if i put a waitUntil ? { _a = getPos player ; _b = getPos player } => _b (could be, by value ) != _a ? Share this post Link to post Share on other sites
UNN 0 Posted April 15, 2009 I'm guessing the UI namespace relates to the UI event handlers mainly, which are strings. (eg: MouseButtonDown, LBListSelChanged, Action, etc). In retrospect, I figure there must be some interaction allowed. Otherwise there is no point in having dialogs, if you can't do anything with them. Share this post Link to post Share on other sites
Gunter Severloh 4067 Posted August 6, 2010 Please dont spam our forums here, if you have nothing to contribute or any problem, or idea that you need help on then dont say anything at all. Share this post Link to post Share on other sites