souldjer777 Posted August 10, 2011 Share Posted August 10, 2011 I'm new - I'm sorry, it's true. I can't seem to modify / delete the column data taken from an internet explorer table that's been passed to an array. I believe I'm looking in all the wrong places - doing all the wrong things... I want to delete the arrays that have blank spaces in them or empty / null values from the results in the listview. I'm lost and burnt out because I must be going about this totally the wrong way for quite a while. Thanks in advance and please don't hate $oIE = _IECreate ("https://awebsiteiloginto") $oForm = _IEFormGetObjByName ($oIE, "loginPage") $oSubmit = _IEGetObjByName ($oIE, "sysverb_login") $oQuery1 = _IEFormElementGetObjByName ($oForm, "user_name") $oQuery2 = _IEFormElementGetObjByName ($oForm, "user_password") _IEFormElementSetValue ($oQuery1, "myname") _IEFormElementSetValue ($oQuery2, "mypassword") _IEAction ($oSubmit, "click") _IELoadWait($oIE) _IENavigate ($oIE, "https://awebsitewhereigetmytabledatafrom") _IELoadWait ($oIE) $array = _IETableGetCollection ($oIE, 19) $array2 = _IETableWriteToArray ($array, True) For $i = 1 ubound($array2) - 1 If $array2[$i] == "" Or $array2[$i] == " " then _ArrayDelete($array2, $i) Next _ArrayDisplay($array2) Picture attached "Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"Song Title: I guess you could sayArtist: Middle Class Rut Link to comment Share on other sites More sharing options...
Spiff59 Posted August 10, 2011 Share Posted August 10, 2011 (edited) The problem is that _ArrayDelete reduces the size of your array each time called. So in your For/Next loop if you're looking at element 20, and delete it, _ArrayDelete shifts all the remaining elements down one slot in your array. The next pass of the loop will look at the "new" element 21, whereas the "old" element 21 is now in slot 20 and will never get reviewed. The bigger issue is that the max value of your For/Next loop is set once when the loop is defined, and deletions to the array will cause out-of-bounds errors as you may eventually be trying to evaluate element 100 of an array that now only contains 99 elements. The easy fix: count backwards in your loop (Step -1) from the end to the beginning, then deletions, that shift elements at the end of the array, will have no effect on the elements yet to be processed. Edited August 10, 2011 by Spiff59 Link to comment Share on other sites More sharing options...
souldjer777 Posted August 10, 2011 Author Share Posted August 10, 2011 (edited) Like this? I've seen examples on other forums so... For $i = Ubound($array2) - 1 to 0 Step - 1 If $array2[$i] == "" Or $array2[$i] == " " then _ArrayDelete($array2, $i) Next "Array variable has incorrect number of subscripts or subscript dimension range exceeded." If $array2[$i] == "" Or $array2[$i] == " " then _ArrayDelete($array2, $i) If ^ ERROR I'm still in the same rut - but thanks for the reply Edited August 10, 2011 by souldjer777 "Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"Song Title: I guess you could sayArtist: Middle Class Rut Link to comment Share on other sites More sharing options...
PowerCat Posted August 10, 2011 Share Posted August 10, 2011 (edited) Like this? I've seen examples on other forums so... For $i = Ubound($array2) - 1 to 0 Step - 1 If $array2[$i] == "" Or $array2[$i] == " " then _ArrayDelete($array2, $i) Next "Array variable has incorrect number of subscripts or subscript dimension range exceeded." If $array2[$i] == "" Or $array2[$i] == " " then _ArrayDelete($array2, $i) If ^ ERROR I'm still in the same rut - but thanks for the reply That array looks like it's a 3d array, try $array2[$i][something] $array2[$i][0] perhaps? or $array2[0][$i] memory blank Edited August 10, 2011 by PowerCat Link to comment Share on other sites More sharing options...
souldjer777 Posted August 11, 2011 Author Share Posted August 11, 2011 Thanks so much ! ! ! For $i = Ubound($array2) - 1 to 0 Step - 1 If $array2[$i][0] == "" Or $array2[$i][0] == " " then _ArrayDelete($array2, $i) Next Worked great display looks good I think "Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"Song Title: I guess you could sayArtist: Middle Class Rut Link to comment Share on other sites More sharing options...
souldjer777 Posted August 12, 2011 Author Share Posted August 12, 2011 (edited) Also, used StringReplace below to remove text from the 2d or 3d array or whatever in autoit to further filter my results while it loops through. This function removes " Total" and replaces it with "" (or nothing) so my results are cleaner. Get's rid of the blank or white space plus the word "total" - so all good and I'm super giddy $array3 = $array2 For $n = Ubound($array3) - 1 to 0 Step - 1 $array3[$n][0]=StringRegExpReplace($array3[$n][0], " Total", "") Next _ArrayDisplay($array3) I'm finally starting to get the whole array thing! woohoo! Edited August 12, 2011 by souldjer777 "Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"Song Title: I guess you could sayArtist: Middle Class Rut 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