Jump to content
Sign in to follow this  
goldenix

[Solved]_ArrayAdd

Recommended Posts

goldenix

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 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]

Share this post


Link to post
Share on other sites
KaFu

#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)

Share this post


Link to post
Share on other sites
goldenix

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 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]

Share this post


Link to post
Share on other sites
KaFu

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)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.