Would there be any way to delete just “Computer Wire” from the array? I found the Array.splice thingy, but it seems that you need to know the index of the thing. Therefore i guess my question is: Is there any way to find the index of a particular value.
In the thing I am making, the value could be at any index in the array (it is put in place by the user), so I could not just say Array.splice(2,1,). Any ideas?
but doesn’t using pop() just take out the last value in an array? I was looking for something that would delete a specific value that could be anywhere in the array, not just in the last space.
For example, an array:
a,r,s,h,p,g,m,n,d
Is there any way that a script could find and delete only the “h”, rather than only delete the last or first part of the array? Or is there some way to move a value to the last part of the array and then use pop() to delete it?
oops, didnt see the “youll have to make a function up” part. Now i am stuck on that. I dont know of any ways to find a value in an array. or did you mean something else…
i dont have the time to test it out… but i think this should do it
// the name of your array goes in arrayname, and the text that you want to be deleted goes in entry
function deleteEntry(arrayname, entry)
{
n=arrayname.length
for(i=0; i<(n+1); i++){
if (arrayname* == entry)
{
arrayname* = ""
break;
}
}
Well… Not really nice one, I guess… That method will work just fine if I have small number of elements in the array… But think about the case when you have to traverse a couple thousand elements to find one and that one happened to be at the end of the array???
ahmed’s arrayname* = “” line should be arrayname.splice(i, 1); to properly delete the item from the array…
is it possible to store an array in a flash shared object, or will it store as a variable and then I would have to convert it back into an array when I get it out of the SO?
i think there was a thread or something on this site about converting variables that were once arrays back into arrays…