marko001 Posted August 12, 2010 Share Posted August 12, 2010 (edited) Hi all, i'm burning my brain trying to solve this. I need to find and extract a value into a var from an array: global $AR_Merge [9] [2] = [ _ [8,16], _ [14,8], _ [12,24], _ [6,8], _ [22,72], _ [18,74], _ [1,400], _ [25,340], _ [7,400]] What I'd like to get is, for example, the value "74" given the value 18" If i use _arraysearch($AR_Merge, 18) it returns, correctly, 5, that's the ROW where 18 is. But i need to extract the 74. Is there a way to do it? (similar to the excel formula SEARCH.VERT or SEARCH.HORIZ) Thanks everyone, Marco Edited August 12, 2010 by marko001 Link to comment Share on other sites More sharing options...
funkey Posted August 12, 2010 Share Posted August 12, 2010 #Include <Array.au3> Local $AR_Merge [9] [2] = [ _ [8,16], _ [14,8], _ [12,24], _ [6,8], _ [22,72], _ [18,74], _ [1,400], _ [25,340], _ [7,400]] Local $Res = _ArraySearch($AR_Merge, 18) ConsoleWrite($AR_Merge[$Res][1] & @cr) Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
FlyinRiz Posted August 12, 2010 Share Posted August 12, 2010 $search = 18 $result = $AR_Merge[_ArraySearch($AR_Merge, $search)][1]You should look into learning a little about 2D Arrays. It might help in understanding how to work with them.-Aaron Link to comment Share on other sites More sharing options...
Schuss Posted August 12, 2010 Share Posted August 12, 2010 #Include <Array.au3> global $AR_Merge [9] [2] = [ _ [8,16], _ [14,8], _ [12,24], _ [6,8], _ [22,72], _ [18,74], _ [1,400], _ [25,340], _ [7,400]] MsgBox(0,"Result",$AR_Merge [_arraysearch($AR_Merge, InputBox("Search Array", "Enter your lookup value.", "18"))] [1]) Link to comment Share on other sites More sharing options...
saywell Posted August 12, 2010 Share Posted August 12, 2010 You should look into learning a little about 2D Arrays. It might help in understanding how to work with them.-AaronYes, the Autoit help is rather scanty in this area - all the examples seem to be 1D. I've been puzzling over the syntax of 2D arrays without much success, so thanks for that link which sheds some light - though some more autoit- specific info would be useful. Eg really basic stuff like ho to specify a bit of data in a given location - I've tried various combinations of paired brackets without success! Looking at the link, it seems to be a pair of numbers, within a single pair of square brackets, separated by a comma.I think it's one of those areas that trained/experienced programmers find so easy that they don't understand why mere mortals find it difficult!So thanks from me, too!William Link to comment Share on other sites More sharing options...
FlyinRiz Posted August 12, 2010 Share Posted August 12, 2010 Yes, the Autoit help is rather scanty in this area - all the examples seem to be 1D. I've been puzzling over the syntax of 2D arrays without much success, so thanks for that link which sheds some light - though some more autoit- specific info would be useful. Eg really basic stuff like ho to specify a bit of data in a given location - I've tried various combinations of paired brackets without success! Looking at the link, it seems to be a pair of numbers, within a single pair of square brackets, separated by a comma. I think it's one of those areas that trained/experienced programmers find so easy that they don't understand why mere mortals find it difficult! So thanks from me, too! William The easiest way to explain it is as such (using books/Excel)... Variable = Word/Cell($var) 1D Array = Line/Row ($array[2]) 2D Array = Page/Worksheet ($array[2][5]) 3D Array = Book/Workbook ($array[2][5][3]) 4D Array = Shelf/Folder of Workbooks ($array[2][5][3][7]) etc... The only other big thing to worry about is whether the reference starts at 0 (C++, AutoIt) or 1 (VB)... So in the above example using an AutoIt array, $array[2][4][1] would refer to the 3nd word of the 5th line in the 2nd book. Make sense? -Aaron Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 13, 2010 Share Posted August 13, 2010 Yes, the Autoit help is rather scanty in this area - all the examples seem to be 1D. I've been puzzling over the syntax of 2D arrays without much success, so thanks for that link which sheds some light - though some more autoit- specific info would be useful. Eg really basic stuff like ho to specify a bit of data in a given location - I've tried various combinations of paired brackets without success! Looking at the link, it seems to be a pair of numbers, within a single pair of square brackets, separated by a comma.Did you try the tutorial at the Wiki? You do know we have a Wiki, right? The big link at the top of the page? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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