Thanks for your reply, Spinor, that worked just right. As a matter of fact I do use conditionals and loops within the script, and since what I'm doing is a pretty long and complicated process, I prefer to declare all local variables involved rather than only those used within the control structures.
As for functions, now I'm trying to do what I had initially intended, but I ran into trouble again.
getunitattrib.sqf
_private = ["_aUNITINFO", "_attrib", "_result"];
_aUNITINFO = _this select 0;
_attrib = _this select 1;
if (_attrib == "GROUP") then
{
_result = (_aUNITINFO select 0);
};
_result
init.sqs
_coso = [(aBLUEUNITS select 3), "GROUP"] call getUnitAttrib;
hintc format["%1", _coso];
(aBLUEUNITS select 3) being an array containing a pointer to a group in its first element (position 0).
Again, _coso is assigned nothing. The problem is in the conditional, since when I put the "_result = (_aUNITINFO select 0);" line out of it, it works perfectly.