d0n Posted July 23, 2009 Share Posted July 23, 2009 Right now i have an array with 250 columns and 5 rows i was wondering how would i go about switching them to 250 rows and 5 columns Link to comment Share on other sites More sharing options...
Beege Posted July 23, 2009 Share Posted July 23, 2009 One way would be create a new array and transfer the values over to it. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Authenticity Posted July 23, 2009 Share Posted July 23, 2009 #include <Array.au3> Global $avArray[3*4*5], $iCounter = 0 For $i = 0 To 3*4*5-1 $avArray[$i] = Random(-200, 200) Next For $i = 0 To 2 For $j = 0 To 4 For $k = 0 To 3 ConsoleWrite($avArray[$i*$j*$k] & @LF) $iCounter += 1 Next Next Next ConsoleWrite('3 * 4 * 5 = ' & $iCounter & @LF) $iCounter = 0 For $i = 0 To 4 For $j = 0 To 3 For $k = 0 To 2 ConsoleWrite($avArray[$i*$j*$k] & @LF) $iCounter += 1 Next Next Next ConsoleWrite('3 * 4 * 5 = ' & $iCounter & @LF) Exit If you'll look closely you'll see that you're accessing the array differently. Link to comment Share on other sites More sharing options...
d0n Posted July 23, 2009 Author Share Posted July 23, 2009 (edited) @Authenticity: i dont really get what you are doing there tbh lol @bchris01: trying that now Question, how do you add to a specific array kind of like _ArrayAdd but for 2D arrays? Edited July 23, 2009 by d0n Link to comment Share on other sites More sharing options...
Beege Posted July 23, 2009 Share Posted July 23, 2009 Do a search for Array2D. There are a couple UDF's written for working with 2D Arrays. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Authenticity Posted July 23, 2009 Share Posted July 23, 2009 #include <Array.au3> Dim $avArr[2][4] = [[1, 2, 3, 4], [5, 6, 7, 8]] ; ... $iRow = UBound($avArr, 1) $iCol = UBound($avArr, 2) ReDim $avArr[$iRow+1][$iCol] $avArr[$iRow][0] = 9 _ArrayDisplay($avArr) I think, by modifying a little bit you can add to an arbitrary size/dimensions array. Link to comment Share on other sites More sharing options...
d0n Posted July 23, 2009 Author Share Posted July 23, 2009 Thanks got it to work now, anyway to improve it? $row = UBound($avArray,1) $col = UBound($avArray,2) Local $avArray2[2][2] = [[""],[""]] ReDim $avArray2[$col][$row] For $i=0 To $col-1 For $j=0 To $row-1 $avArray2[$i][$j] = $avArray[$j][$i] Next Next _ArrayDisplay($avArray2) Link to comment Share on other sites More sharing options...
Beege Posted July 23, 2009 Share Posted July 23, 2009 Thats something like I was thinking. I dont think there is going to be a much faster way.. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
icu Posted October 14, 2011 Share Posted October 14, 2011 (edited) For anyone looking for a cut and paste UDF: Func _ArrayColumnsToRows (ByRef $avArray) $row = UBound($avArray,1) $col = UBound($avArray,2) Local $avArray2[$col][$row] For $i=0 To $col-1 For $j=0 To $row-1 $avArray2[$i][$j] = $avArray[$j][$i] Next Next Return $avArray2 EndFunc ;=> _ArrayColumnsToRows Edited October 14, 2011 by icu Link to comment Share on other sites More sharing options...
Spiff59 Posted October 14, 2011 Share Posted October 14, 2011 Thanks got it to work now, anyway to improve it? Why 2 lines here Local $avArray2[2][2] = [[""],[""]] ReDim $avArray2[$col][$row] One line is sufficient Local $avArray2[$col][$row] 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