goldenix Posted April 30, 2009 Share Posted April 30, 2009 (edited) I need to fill an array. it must have 2 columns: Col1 = handles & col2 = treeitem name. cuz im not a computer & handles tell me nothing, so this is the code I use to fill the array, but it has only 1 column. How can I create another column? imagine that list of the items in the array is dynamic = atm there are 10 items in the array, but in reality instead of 10 there will be a variable. #include <Array.au3> Global $aItem_Handles[1] For $x = 1 To 10 _ArrayAdd($aItem_Handles, $x) Next _ArrayDisplay($aItem_Handles) Edited April 30, 2009 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
Developers Jos Posted April 30, 2009 Developers Share Posted April 30, 2009 http://www.autoitscript.com/forum/index.ph...mp;hl=_arrayadd SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
KaFu Posted April 30, 2009 Share Posted April 30, 2009 #include <Array.au3> Global $aItem_Handles[1] $y = 10 ReDim $aItem_Handles[$y+1][2] For $x = 1 To $y $aItem_Handles[$x][0] = "Value" $aItem_Handles[$x][1] = $x Next _ArrayDisplay($aItem_Handles) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
goldenix Posted April 30, 2009 Author Share Posted April 30, 2009 (edited) I was hoping there would me more simple way that will add values/rows,column. auto if they do not exist. like _arrayadd(row,column) Issue solved. #include <Array.au3> Dim $aItem_Handles[1][2] For $x = 1 To 10 ReDim $aItem_Handles[$x][2] $iRow = UBound($aItem_Handles) ;add Rows $iCol = UBound($aItem_Handles, 2) ;Add Columns ReDim $aItem_Handles[$iRow + 1][$iCol] ; add more rows +1 ; ReDim $avArray[$iRow + 1][$iCol + 1] - Adds both $aItem_Handles[$x][0] = $x $aItem_Handles[$x][1] = $x Next _ArrayDisplay($aItem_Handles) Edited April 30, 2009 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
KaFu Posted April 30, 2009 Share Posted April 30, 2009 Avoid Redim within the loop at all cost! #include <Array.au3> ; Variant A Dim $aItem_Handles[1][2] $timer = TimerInit() For $x = 1 To 1000 ReDim $aItem_Handles[$x][2] $iRow = UBound($aItem_Handles) ;add Rows $iCol = UBound($aItem_Handles, 2) ;Add Columns ReDim $aItem_Handles[$iRow + 1][$iCol] ; add more rows +1 ; ReDim $avArray[$iRow + 1][$iCol + 1] - Adds both $aItem_Handles[$x][0] = $x $aItem_Handles[$x][1] = $x Next ConsoleWrite("A took " & TimerDiff($timer) & " ms" & @crlf) ;_ArrayDisplay($aItem_Handles) ReDim $aItem_Handles[1][2] ; Variant B $timer = TimerInit() $y = 1000 ReDim $aItem_Handles[$y+1][2] For $x = 1 To $y $aItem_Handles[$x][0] = $x $aItem_Handles[$x][1] = $x Next ConsoleWrite("B took " & TimerDiff($timer) & " ms" & @crlf) ;_ArrayDisplay($aItem_Handles) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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