Jump to content
Sign in to follow this  
cfsfirefighter

Nested Array's

Recommended Posts

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

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

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

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 by KevsnoTrev
^^^^ too slow it seems!

Share this post


Link to post
Share on other sites

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×