cfsfirefighter 1 Posted September 30, 2013 Hey guys im having an issue so here is my array my_array = [[apple,box,cat], [1,2,3], [fish,jar,car]]; Now i have a ListnBox dialog which lists this all the nested array's and a button that when i click it it formats and sends 1 of the nested array to sidechat for example Cfsfirefighter has a [u]FISH[/u] in a [u]JAR[/u] which he drives around in his [u]CAR[/u] Now after that has been displayed i want it to remove that nested array completely so i know i need to use the following command to do that my_array set [2,"Delete"]; However because the selection is made from a ListnBox dialog i need it to automatically get the index of that array and set it to "Delete" then i can run the following code my_array = my_array - ["Delete"]; Any help would be great thanks Cfsfirefighter Share this post Link to post Share on other sites
cfsfirefighter 1 Posted September 30, 2013 What i really need is something like my_array find [fish,jar,car]; However that doesn't work with nested arrays Share this post Link to post Share on other sites
shuko 59 Posted September 30, 2013 If the listbox doesnt return the index, then maybe just create a function which foreach/for-loops through your array and checks for the wanted array? Does this lbCurSel help? Share this post Link to post Share on other sites
2nd ranger 282 Posted September 30, 2013 Check out BIS_fnc_removeIndex in the functions viewer. Since presumably you can get the index of the nested array when the button is clicked, you should just be able to do this: _result = [my_array, 2] call BIS_fnc_removeIndex; Although the function doesn't actually modify the existing array, it just creates a copy. So you'd have to replace the original array with the new one. Share this post Link to post Share on other sites
KevsNoTrev 44 Posted September 30, 2013 (edited) Hey firefighter, check the function viewer in the editor - it has a section called array and there are quite a few in there that might do what you are after. BIS_fnc_removeNestedElement might do the trick. Edited September 30, 2013 by KevsnoTrev ^^^^ too slow it seems! Share this post Link to post Share on other sites
2nd ranger 282 Posted September 30, 2013 removeNestedElement doesn't remove nested arrays though, it just removes elements in a nested array. Share this post Link to post Share on other sites