Champak Posted February 14, 2012 Share Posted February 14, 2012 i'm sure this has been asked for before, but i dont know exactly what to search for. I get an array with a set amount of rows (4) and variable amount of columns. I want to convert the array and contents to a set amount of columns (4) and variable amount of rows. I hope I'm clear on that. Thanks. Link to comment Share on other sites More sharing options...
water Posted February 14, 2012 Share Posted February 14, 2012 You need a transpose function. Something like My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
UEZ Posted February 14, 2012 Share Posted February 14, 2012 (edited) You mean something like this: expandcollapse popup#include <array.au3> Global $aTest[4][3] = [ [1, 2, 3], _ [4, 5, 6], _ [7, 8, 9], _ [10, 11, 12]] $aRot = ArrayRotate($aTest, 90) _ArrayDisplay($aRot) $aRot = ArrayRotate($aTest, 180) _ArrayDisplay($aRot) Func ArrayRotate($aArray, $iDeg) ;coded by UEZ 2012 build 2012-02-15 If Not IsArray($aArray) Then Return SetError(1, 0, 0) ;not an array If Not UBound($aArray, 0) = 2 Then Return SetError(2, 0, 0) ;not a 2D array If Mod($iDeg, 90) Then Return SetError(3, 0, 0) ;only 90° rotations allowed Local $i, $j, $k = 0, $l = 0 Switch $iDeg Case 90, -270 Local $aRotated[UBound($aArray, 2)][UBound($aArray)] For $i = 0 To UBound($aArray, 2) - 1 For $j = UBound($aArray) -1 To 0 Step - 1 $aRotated[$i][$k] = $aArray[$j][$i] $k += 1 Next $k = 0 Next Return $aRotated Case 270, -90 Local $aRotated[UBound($aArray, 2)][UBound($aArray)] For $i = UBound($aArray, 2) - 1 To 0 Step - 1 For $j = 0 To UBound($aArray) - 1 $aRotated[$l][$k] = $aArray[$j][$i] $k += 1 Next $l += 1 $k = 0 Next Return $aRotated Case 180, -180 Local $aRotated[UBound($aArray)][UBound($aArray, 2)] For $i = UBound($aArray) - 1 To 0 Step - 1 For $j = UBound($aArray, 2) - 1 To 0 Step - 1 $aRotated[$l][$k] = $aArray[$i][$j] $k += 1 Next $l += 1 $k = 0 Next Return $aRotated EndSwitch EndFunc Br, UEZ Edited February 15, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
spudw2k Posted February 14, 2012 Share Posted February 14, 2012 Yet another example.I like the rotation UEZ Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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