cjconstantine Posted December 13, 2006 Share Posted December 13, 2006 Ok, I obviously don't know if this UDF already exists (which is why I wrote it). I've got a bunch of two dimensional arrays that I have to manipulate the heck out of. One of the things that needs to be done is the removal of a row of data based on a string value, so I wrote this: CODEFunc _2DArrayDelete($array, $iIndex, $iSort, $search) #cs =================================================== Function: This function will delete a 'row' of data from a 2-D array and return the adjusted array. Required: #include <Array.au3> $array = 2-Dimensional array to be processed $iIndex = The starting 'column' of the array that will be moved up. (ie, if there is data in [n][0] and [n][1] that doesn't need to be moved along with [n][2] - [n][x] then this value would be set to 2). $iSort = The 'column' to sort; array is sorted in asending order based on the 'column' at this value. $search = The string that will be searched for in the $iSort 'column'. #ce =================================================== _ArraySort($array, 0, 1, -1, UBound($array, 2), $iSort) $start = 0 $end = 0 For $x = 1 To $array[0][0] If $start = 0 And $array[$x][$iSort] = $search Then $start = $x If $start > 0 And $array[$x][$iSort] = $search Then $end = $x If $array[$x][$iSort] > $search Then ExitLoop Next $move = $end - $start + 1 For $x = $start To $array[0][0]-$move For $y = $iIndex To UBound($array, 2)-1 $array[$x][$y] = $array[$x+$move][$y] Next Next $array[0][0] -= $move ReDim $array[$array[0][0]+1][uBound($array, 2)] Return $array EndFunc I know my documentation isn't the clearest in the world, but that's the best I could do. I know how it works in my head, but I couldn't translate well to e-paper. Lemme know what you think. Link to comment Share on other sites More sharing options...
randallc Posted December 13, 2006 Share Posted December 13, 2006 Hi, Thanks; a detailed set of parameters! I have an "_ArrayDelete2D" in my array2D.au3 UDF, not so detailed , linked from my signature; could I include yours as an option in that UDF? best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
cjconstantine Posted December 13, 2006 Author Share Posted December 13, 2006 Hi,Thanks; a detailed set of parameters!I have an "_ArrayDelete2D" in my array2D.au3 UDF, not so detailed , linked from my signature; could I include yours as an option in that UDF?best, RandallMost definately! Maybe change the name to _ArrayDelete2DRowSearch or something since it will only delete a row that contains the search string. 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