MaxPower44 1 Posted February 11, 2003 I have write a function like this:</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">private {_param1,param2,_count}; _param1 = _this select 0; _count = 0; _return = 1; while (_count < _param1) do {  _return = _return * _param1;  _param1 = _param1 - 1; }; _return<span id='postcolor'> And i call like this :</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_count=0; _array = [1,2,45,18] #loop  player sidechat format["%1", [_array select _count] call mafunction ?(_count< count _array):goto "Loop"<span id='postcolor'> But, i mean that my variable _count of the script is modify by the function, or not ? I should change the _count in script by _count2, what's wrong ? Share this post Link to post Share on other sites
Guest Posted February 11, 2003 "_count" is a local variable. It should not be modified by the function. Share this post Link to post Share on other sites
Spinor 0 Posted February 11, 2003 I think, the variables are not properly 'privatized' in your function. The private command should look like: private ["_param1", "_param2", "_count"]; Share this post Link to post Share on other sites
MaxPower44 1 Posted February 11, 2003 You're probable right, in the example in comref, i saw :</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Â Â private {"_a","_b"}; Â Â _a = _this select 0; Â Â _b = _this select 1; Â Â if (_a>_b) then {_a} else {_b}<span id='postcolor'> But I make :</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Â Â private {_a,_b}; Â Â _a = _this select 0; Â Â _b = _this select 1; Â Â if (_a>_b) then {_a} else {_b}<span id='postcolor'> Thx Share this post Link to post Share on other sites
Spinor 0 Posted February 11, 2003 Make sure to use square brackets though, its private ["_a", "_b"]; and not private {"_a", "_b"}; Share this post Link to post Share on other sites
MaxPower44 1 Posted February 11, 2003 private {"_a", "_b"} is an error in comref ? Share this post Link to post Share on other sites
Guest Posted February 11, 2003 private ["_a","_b"] is the standard variant. I havn't tried the other. It would be however strange that it works since curled brackets are the same as string delimiters. {hello world} = "hello world" Share this post Link to post Share on other sites
MaxPower44 1 Posted February 11, 2003 probably right ! I should try Thx Share this post Link to post Share on other sites
MaxPower44 1 Posted February 11, 2003 It works better with [] instead of {} Thx Share this post Link to post Share on other sites