datkewlguy Posted April 22, 2010 Posted April 22, 2010 I'm trying to take a square amount of text (4x4), for example: abcdefghijklmnop and assign it to an array so that it could be visually represented as abcd efgh ijkl mnop then I should be able to say Msgbox(0, "", $array[3][2] ) and have it return "j" because that's the value in the 3rd row, 2nd column. I'm still learning multidimensioanl arrays, so if this is possible, i'd really appreciate the help. Thanks
Fulano Posted April 22, 2010 Posted April 22, 2010 It looks like you've pretty well got it (syntax looks right, etc), what's the question? #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
ProgAndy Posted April 22, 2010 Posted April 22, 2010 (edited) $array[3][2] would most likely return O since Array dimensions in AutoIt are zero-based. To access the second col in the third row, you have to use $array[2][1] Here is a PDF i made some time ago: MultiDimArrays.pdf Edited April 22, 2010 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
PsaltyDS Posted April 22, 2010 Posted April 22, 2010 To declare it that way: Global $aArray[4][4] = [["a", "b", "c", "d"], ["e", "f", "g", "h"], ["i", "j", "k", "l"], ["m", "n", "o", "p"]] ConsoleWrite("[3][2] = " & $aArray[3][2] & @LF) To take a string of unknown length and split it in columns of 4: Global $aArray[1][1], $sString = "abcdefghijklmnopqrs" $iRows = Ceiling(StringLen($sString) / 4) ReDim $aArray[$iRows][4] For $r = 0 To $iRows - 1 For $c = 0 To 3 $aArray[$r][$c] = StringMid($sString, ($r * 4) + 1 + $c, 1) Next Next ConsoleWrite("[3][2] = " & $aArray[3][2] & @LF) Notice that either way $aArray[3][2] is "o", because array indexes are 0-based. So that's the fourth row, third column. 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
datkewlguy Posted April 22, 2010 Author Posted April 22, 2010 Wow, thanks guys. That helps. I actually wrote a lot of the code that you gave me already, I think I was just missing a couple things.
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