czervika Posted May 7, 2009 Share Posted May 7, 2009 This has probably been covered somewhere several hundred times but for the life of me I cann't find much information so I guess I'll start a new thread. So I'm new to the whole programming/scripting thing and I've come to a point where I need help. Removing an element from an array. I'sure i can do something like array[x] = 0 or something similar. My question is what is best practice? assign 0, Null, re-index the array? For a little help I'll throw out this example. A directory exists that contains files named; 1.exe 2.exe 3.exe 4.exe 7.exe 8.exe 9.exe 10.exe A user inputs a comma seperated string into an input box containing; 1,2,3,4,5,6,7,8,9,10, stringsplit reads that string to an array. Obviously 5 and 6 don't exist. So as the script loops through to verify the files exist, errors generated on 5 and 6. So to remove the offending elements, how does one handle that? I believe I could set the element to 0 and on the subsequent loops to execute files if the element is 0, continue to the next element. But is this the correct way to handle this situation? TIA Bill Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 7, 2009 Moderators Share Posted May 7, 2009 This has probably been covered somewhere several hundred times but for the life of me I cann't find much information so I guess I'll start a new thread. So I'm new to the whole programming/scripting thing and I've come to a point where I need help. Removing an element from an array. I'sure i can do something like array[x] = 0 or something similar. My question is what is best practice? assign 0, Null, re-index the array? For a little help I'll throw out this example. A directory exists that contains files named; 1.exe 2.exe 3.exe 4.exe 7.exe 8.exe 9.exe 10.exe A user inputs a comma seperated string into an input box containing; 1,2,3,4,5,6,7,8,9,10, stringsplit reads that string to an array. Obviously 5 and 6 don't exist. So as the script loops through to verify the files exist, errors generated on 5 and 6. So to remove the offending elements, how does one handle that? I believe I could set the element to 0 and on the subsequent loops to execute files if the element is 0, continue to the next element. But is this the correct way to handle this situation? TIA BillThe easiest way (most straight forward) is to just use _ArrayDelete() that's provided for you. If you're trying to learn about autoit and arrays: http://www.autoitscript.com/wiki/Arrays Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
czervika Posted May 7, 2009 Author Share Posted May 7, 2009 (edited) The easiest way (most straight forward) is to just use _ArrayDelete() that's provided for you.If you're trying to learn about autoit and arrays:http://www.autoitscript.com/wiki/ArraysThank you.After looking over the help file for that it's exactly what I'm after. Thanks again. Edited May 7, 2009 by czervika Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now