Jump to content
Sign in to follow this  
wimhek

Array Add question

Recommended Posts

wimhek

Can I add the function arrayadd with a 2 dimension array , and if yes, how ?

Share this post


Link to post
Share on other sites
Jos

you can do this by using redim and setting the newly created "sockets" in the array.

This is what _ArrayAdd() does on a single dimension array.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
wimhek

you can do this by using redim and setting the newly created "sockets" in the array.

This is what _ArrayAdd() does on a single dimension array.

Thakks for your quick answer, but how can I do the redim ? I made this example :

#include <Array.au3>

dim $aaa[1][2]

_ArrayDisplay($aaa)

$aaa [0][0] = "Ape"

$aaa [0][1] = "Nut"

_ArrayDisplay($aaa)

_arrayadd($aaa,"Mary")

_ArrayDisplay($aaa)

Share this post


Link to post
Share on other sites
Jos

You sure you looked in the helpfile? ^_^

#include <Array.au3>
dim $aaa[1][2]
_ArrayDisplay($aaa)
$aaa [0][0] = "Ape"
$aaa [0][1] = "Nut"
_ArrayDisplay($aaa)
ReDim $aaa[1][3]
$aaa [0][2] = "Mary"
_ArrayDisplay($aaa)

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
wimhek

You sure you looked in the helpfile? ^_^

Jos

Jos of course I did, but what I want in the end is an arry in this structure

Row Col0 Col1

0 Ape Nut

1 Mary William

Share this post


Link to post
Share on other sites
Jos

something like this should then work for you i guess:

#include <Array.au3>
Dim $aaa[1][2]
_ArrayDisplay($aaa)
_MyAddrayAdd("Ape", "Nut")
_ArrayDisplay($aaa)
_MyAddrayAdd("Mary", "Wim")
_ArrayDisplay($aaa)


Func _MyAddrayAdd($d1, $d2)
    ReDim $aaa[UBound($aaa) + 1][UBound($aaa, 2) + 1]
    $aaa[UBound($aaa) - 1][0] = $d1
    $aaa[UBound($aaa) - 1][1] = $d2
EndFunc  ;==>_MyAddrayAdd

Enjoy,

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
wimhek

Enjoy,

Jos

Thnx it works, I deleted the +1 in the redim command to avoid adding columns.

#include <Array.au3>

Dim $aaa[1][2]

_ArrayDisplay($aaa)

_MyAddrayAdd("Ape", "Nut")

_ArrayDisplay($aaa)

_MyAddrayAdd("Mary", "Wim")

_ArrayDisplay($aaa)

_MyAddrayAdd("Sister", "Tony")

_ArrayDisplay($aaa)

Func _MyAddrayAdd($d1, $d2)

ReDim $aaa[uBound($aaa) + 1][uBound($aaa, 2) ]

$aaa[uBound($aaa) - 1][0] = $d1

$aaa[uBound($aaa) - 1][1] = $d2

EndFunc ;==>_MyAddrayAdd

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  

×