I am wondering if people would be interested in this kind of functionality.
Attached Files
Edited by P5ych0Gigabyte, 18 January 2010 - 10:22 PM.
Posted 31 October 2006 - 03:17 AM
Edited by P5ych0Gigabyte, 18 January 2010 - 10:22 PM.
Posted 31 October 2006 - 10:20 PM
Posted 31 October 2006 - 10:37 PM
Posted 01 November 2006 - 12:16 AM
Posted 01 November 2006 - 12:23 AM
Posted 01 November 2006 - 01:04 AM
Couple thoughts:
1. Right now it returns as soon as something is found, perhaps it should continue checking? Basically, what should it do if there are multiple entries of the same thing?
2. It would be pretty sweet for it to return both indeces when searching as well, otherwise the search has to be performed twice.
These *may* be out of scope, thought i'd ask though and see what you thought.
Edited by SolidSnake, 01 November 2006 - 01:05 AM.
Posted 01 November 2006 - 01:23 AM
Posted 01 November 2006 - 01:31 AM
I say maybe useful in certain circumstances. I can see the ability for it to be used, but fail to see mass use. I'm sure most AutoIt users will find a use for it at least once in their scripts, but not very often.
Edited by SolidSnake, 01 November 2006 - 01:32 AM.
Posted 01 November 2006 - 02:43 AM
Posted 01 November 2006 - 02:59 AM
i absolutely NEEDED this dude, thx a ton!
Posted 13 December 2006 - 12:22 PM
Posted 13 December 2006 - 02:48 PM
Posted 14 December 2006 - 03:16 AM
Should work with any array.Hi,
I am confused; the examples are only using 2D arrays . Does it really work for any number of dimensions, or only 1 or 2D?
best, randall
Dim $Array[3][2][2] $Array[0][1][1] = 1 $Array[1][1][1] = 2 $Array[2][1][1] = 3 $Result = _ArraySearchAnyDim ($Array, "2", 0, 0, 0, "[x][1][1]") ;_ArraySearchAnyDim should return 1 ConsoleWrite($Result & "|" & @error & @LF)
Edited by SolidSnake, 14 December 2006 - 03:17 AM.
Posted 14 December 2006 - 03:19 AM
@SolidSnake
I was planning to write some array searching code for a task that I am working on at present and came across your post by luck while browsing through the Example Scripts, hopefully I'll be able to use your code instead, will certainly have a close look.
Either way I think array functions like this are alway going to be useful, computers are good at working with data so that means there always going to be people writing code to sort/search data. May not be every user, but the need will always be there.
VW
Edited by SolidSnake, 14 December 2006 - 03:19 AM.
Posted 23 February 2007 - 08:49 PM
Posted 24 February 2007 - 12:44 PM
NP.I just started working on a script that needs a multi-dimensional array search. I'm glad I found yours before I started writing one. I'll be testing it to death, and will let you know if I find anything.
Thanks!
This function combines the features of two different versions of _ArraySearch().
TheGuy0000's _ArraySearch()
SolidSnake's _ArraySearchAnyDim()
Edited by SolidSnake, 24 February 2007 - 12:45 PM.
Posted 26 February 2007 - 09:26 PM
I saw that - those extra search features haven't hit any of my needs yet, but I was thinking....NP.
Glad you have a use for it. If you are looking for even more features then check out _ArraySearchPlus()
Posted 26 February 2007 - 11:15 PM
I saw that - those extra search features haven't hit any of my needs yet, but I was thinking....
What if I added a binary search to all of that (ArraySearch++?) So far, I've been able to get enough performance out of my script by not doing redims and other tweaks, but I am doing a bunch of searching in multi-dimensional arrays, so it would probably pay to sort it and then binsearch it. Has anyone else started on this, or should I go for it?
Edited by SolidSnake, 26 February 2007 - 11:17 PM.
Posted 30 December 2007 - 11:20 PM
#cs up to 4 dimensions $avArray is the input array $sFind is a string of what to find $sDimension is a string representing where to look "[-1][3]" will search all the entire first dimension and only the third subset of the second dimension "[3,5][-1][3]" will search the 3rd through 5th of d1, all of d2, and the 3rd of d3 $bAll, if true, returns all values in a two-dimensional array with array[0][0] being the number of values [1][0] will be first dimension's index, [1][2] will be third dimension's index [2][0] will be second answer's first dimension's index $bAll, if false, will return a single-dimensional array with [0] being d1's index [3] being d4's index $iCaseSensative - see StringCompare Help #ce Func _ArraySearchMultiDim($avArray, $sFind, $sDimension, $bAll = True, $iCaseSensative = 0) Local $w, $x, $y, $z Local $dimensions = UBound($avArray,0), $lastBreak = 1, $currentDim = 0 Local $start[$dimensions], $end[$dimensions], $i[$dimensions] If $bAll Then Local $final[1][$dimensions] $final[0][0] = 0 Else Local $final[$dimensions] EndIf For $z = 3 To StringLen($sDimension) $char = StringMid($sDimension,$z,1) If $char = "," Then $start[$currentDim] = StringMid($sDimension,$lastBreak+1,$z-$lastBreak-1) For $y = $z+1 To StringLen($sDimension) If StringMid($sDimension,$y,1) = "]" Then $end[$currentDim] = StringMid($sDimension,$z+1,$y-$z-1) $lastBreak = $y+1 $currentDim += 1 $z = $y+2 ExitLoop EndIf Next ElseIf $char = "]" Then $between = StringMid($sDimension,$lastBreak+1,$z-$lastBreak-1) If $between = "-1" Then $start[$currentDim] = 0 $end[$currentDim] = UBound($avArray,1) Else $start[$currentDim] = Number($between) $end[$currentDim] = Number($between) EndIf $lastBreak = $z+1 $currentDim += 1 $z += 2 EndIf Next For $z = $start[0] To $end[0] If $dimensions = 1 Then If StringCompare($avArray[$z],$sFind,$iCaseSensative) = "0" Then If $bAll Then ReDim $final[UBound($final)+1][$dimensions] $final[0][0] += 1 $final[$final[0][0]][0] = $z Else $final[0] = $z Return $final EndIf EndIf Else For $y = $start[1] To $end[1] If $dimensions = 2 Then If StringCompare($avArray[$z][$y],$sFind,$iCaseSensative) = "0" Then If $bAll Then ReDim $final[UBound($final)+1][$dimensions] $final[0][0] += 1 $final[$final[0][0]][0] = $z $final[$final[0][0]][1] = $y Else $final[0] = $z $final[1] = $y Return $final EndIf EndIf Else For $x = $start[2] To $end[2] If $dimensions = 3 Then If StringCompare($avArray[$z][$y][$x],$sFind,$iCaseSensative) = "0" Then If $bAll Then ReDim $final[UBound($final)+1][$dimensions] $final[0][0] += 1 $final[$final[0][0]][0] = $z $final[$final[0][0]][1] = $y $final[$final[0][0]][2] = $x Else $final[0] = $z $final[1] = $y $final[2] = $x Return $final EndIf EndIf Else For $w = $start[3] To $end[3] If StringCompare($avArray[$z][$y],$sFind,$iCaseSensative) = "0" Then If $bAll Then ReDim $final[UBound($final)+1][$dimensions] $final[0][0] += 1 $final[$final[0][0]][0] = $z $final[$final[0][0]][1] = $y $final[$final[0][0]][2] = $x $final[$final[0][0]][3] = $w Else $final[0] = $z $final[1] = $y $final[2] = $x $final[3] = $w Return $final EndIf EndIf Next EndIf Next EndIf Next EndIf Next Return $final EndFuncoÝ÷ Øi®Ún¢é]mæ¥Ûeyö¬µêÛºÖæ¬¶+p¢¹,Më-±Êâ¦Ö®¶sdvÆö&Âb33c·FW7D'&³%Õ³5Õ³EÐ ¢b33c·FW7D'&³Õ³Õ³ÒÒ¢b33c·FW7D'&³Õ³Õ³ÒÒP¢b33c·FW7D'&³Õ³Õ³%ÒÒ@²fÇC²Ð¢b33c·FW7D'&³Õ³Õ³5ÒÒ²fÇC²Ð¢b33c·FW7D'&³Õ³Õ³ÒÒ¢b33c·FW7D'&³Õ³Õ³ÒÒ`¢b33c·FW7D'&³Õ³Õ³%ÒÒ²fÇC²ÒW0¢b33c·FW7D'&³Õ³Õ³5ÒÒ ²fÇC²Ð¢b33c·FW7D'&³Õ³%Õ³ÒÒ¢b33c·FW7D'&³Õ³%Õ³ÒÒ ¢b33c·FW7D'&³Õ³%Õ³%ÒÒ@²fÇC²Ð¢b33c·FW7D'&³Õ³%Õ³5ÒÒ²fÇC²ÒW0¢b33c·FW7D'&³Õ³Õ³ÒÒ¢b33c·FW7D'&³Õ³Õ³ÒÒ0¢b33c·FW7D'&³Õ³Õ³%ÒÒ¢b33c·FW7D'&³Õ³Õ³5ÒÒP¢b33c·FW7D'&³Õ³Õ³ÒÒp¢b33c·FW7D'&³Õ³Õ³ÒÒ¢b33c·FW7D'&³Õ³Õ³%ÒÒ@¢b33c·FW7D'&³Õ³Õ³5ÒÒ¢b33c·FW7D'&³Õ³%Õ³ÒÒ¢b33c·FW7D'&³Õ³%Õ³ÒÒ3`¢b33c·FW7D'&³Õ³%Õ³%ÒÒ@¢b33c·FW7D'&³Õ³%Õ³5ÒÒ ¢b33c·FW7DfæÂÒô'&6V&6×VÇFFÒb33c·FW7D'&ÃÂgV÷Cµ³Õ²ÓÕ³"Ã5ÒgV÷C² ¤f÷"b33c·¢ÒFòb33c·FW7DfæÅ³Õ³Ð f÷"b33c·ÒFò 6öç6öÆUw&FRgV÷C²b33c·FW7DfæÅ²gV÷C²fײb33c·¢fײgV÷CµÕ²gV÷C²fײb33c·fײgV÷CµÒÒgV÷C²fײb33c·FW7DfæÅ²b33c·¥Õ²b33c·ÒfײgV÷C²âgV÷C²fײ5$Äb æW@¤æW@oÝ÷ ÙK"®¶sbb33c·FW7DfæÂÒô'&6V&6×VÇFFÒb33c·FW7D'&ÃÂgV÷Cµ³Õ²ÓÕ³"Ã5ÒgV÷C²ÂfÇ6R ¤f÷"b33c·ÒFò 6öç6öÆUw&FRgV÷C²b33c·FW7DfæÅ²gV÷C²fײb33c·fײgV÷CµÒÒgV÷C²fײb33c·FW7DfæÅ²b33c·ÒfײgV÷C²âgV÷C²fײ5$Äb¤æW@
Posted 17 February 2012 - 04:47 PM
0 members, 0 guests, 0 anonymous users