Jump to content
Sign in to follow this  
MadMonk

Passing array and other parameters into function

Recommended Posts

Im writing a function to search an array of objects for a particular type and also test for parameter values stored against that object. If the object matches and the two parameters also match, the object is then added to an array in the function and passed back to the caller.

Is it possible to pass an array into a function, along with other parameters like this - :

NewArray = [PublicSensorArray,"snsball",1,0,2,50,7] Call ArraySearch;

This is the function header -:

private ["_SearchArray","_Item1","_Element1","_Element1Value","_Element2","_Element2Value","_ElementsPerItem"];	

//Get passed over variables
_Array = _this Select 0;    			//Passed over array
_UnitType = _this  Select 1;			//Object type to look for
_Element1 = _this  Select 2;			//Element number
_Element1Value = _this  Select 3;		//Element Item
_Element2 = _this  Select 4;			//Element number
_Element2Value = _this  Select 5;		//Element Item
_ObjectElements = _this Select 6;   	//Number of elements for each object

Im sure its something to do with how I'm specifying the array in the calling code but I've tried several ways of formatting this and it keeps throwing

an error. Does anyone have any suggestions for the formatting?

Share this post


Link to post
Share on other sites

yes you can, just add another set of brackets inside your array:

NewArray = [ [item1, item2, item3, item4], "snsball", 1, 0, 2, 50, 7] call ArraySearch;

make sure your array variable is indeed set up as an array.

in your paramters afterwards you can do:

 _Array_element_1 = _Array select 0; // or (this select 0) select 0

Share this post


Link to post
Share on other sites

Excellent, thanks for your help. I'm going crazy on functions at the moment, hoping to build a bit of a tool kit.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×