OneStiffRod 0 Posted March 2, 2003 Firstly tell me the proper way to create an array - the script reference does a terrible job at actually showing syntax. is it: _myarray [0,0,0,0,0] like this? or _myarray = Array(10) can I do it like this? 2ndly, I need to have psuedo objects like classes in C++, I can do this with a 2D array but not sure if OFP will recognize. Share this post Link to post Share on other sites
Guest Posted March 2, 2003 Proper syntax: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_myArray = [1,2,3,4] <span id='postcolor'> 2D arrays (matrices) </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _myArray = [ [1,2] , [3,4] ] <span id='postcolor'> To access the elements of the matrix, use </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _element = (_myArray select _row) select _column <span id='postcolor'> The arrays can contain any type of objects and you can mix them as you wish. </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _myArray = [ [1,"Hello"],["world",2.3456] ] Hint format ["%1 %2", (_myArray select 0) select 1, (_myArray select 1) select 0] <span id='postcolor'> Share this post Link to post Share on other sites
OneStiffRod 0 Posted March 3, 2003 Thank you. U answered it. Share this post Link to post Share on other sites