Sign in to follow this  
Followers 0

An experiment in Multidimensional searches

1 post in this topic

I have a UDF include file written that implements my experiment in multidimensional array searches. The file is _ArrayMultiSearch.au3, and it contains two functions: _ArrayMultiSearch() and _MultiCompare()

The _ArrayMultiSearch() function makes use of the _MultiCompare() function.

_ArrayMultiSearch($avArray, $sData[, $sType]) where:

$avArray = Array to be searched, can have from 1 to 10 dimensions

$sData = Data to search for in $avArray

$sType = (Optional) Compare type to apply, defaults to '=', other valid operators are: '==', '<>', '>', '>=', '<', and '<='

The _ArrayMultiSearch() function searches a given array and returns a one-dimensional array containing the coordinates of all cells that match the criteria given. The searched array is not changed or sorted in the process. The returned array's [0] cell contains the number of results that matched, [0] = 0 if no matches. Cells 1 thru n of the returned array contain multidimensional coordinates of matching cells, with dimensions comma delimited, i.e. 2,6,0,3 is the coordinate for $avArray[2][6][0][3].

_MultiCompare($sCellData, $sData, $sType) where:

$sCellData = Data read from one of the cells of $avArray

$sData = The data to compare to

$sType = (Optional)Compare type to use, defaults to '=' (as above)

This functions returns a 1 for true or 0 for false after comparing $sCellData to $sData. For example,

_MultiCompare($sCellData, $sData, '>=') returns a 1 if $sCellData >= $sData is true.

Works for me, but I just finished it and haven't tested much yet. Sleep and coffee first... :lmao:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0