Sign in to follow this  
Followers 0
sensalim

Can _ArrayAdd work with multi-dim array?

3 posts in this topic

Let's say I have a 2D array, how do I add them using for loop?

Source:

1=description 1

title=title 1

price=100

title=title 1b

price=99

2=description 2

title= title 2

price=80

Desired final array:

1 // title 1 // 100

1 // title 1b // 99

2 // title 2 // 80

How do I do that?

Thanks!

Share this post


Link to post
Share on other sites



Can _ArrayAdd work with multi-dim array?

Nope -> manual: @error: 2 -> $avArray is not a 1 dimensional array.

Leaving the code request for others.

In the mean time you could take a look(help) at Ubound() and ReDim.


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Let's say I have a 2D array, how do I add them using for loop?

Source:

1=description 1

title=title 1

price=100

title=title 1b

price=99

2=description 2

title= title 2

price=80

Desired final array:

1 // title 1 // 100

1 // title 1b // 99

2 // title 2 // 80

How do I do that?

Thanks!

Try:

#include <Array.au3>
Global $First[2][3] = [["1", "title 1", "100"],["1", "title 1b", "99"]]
Global $Second[2][3] = [["2", "title 2", "80"],["2", "title 2b", "79"]]
$1 = UBound($First)
$2 = UBound($Second)
$3 = $1 + $2
$4 = 0
ReDim $First[$1 + $2][3]
For $i1 = $1 To $3 - 1
 For $i2 = 0 To 2
  $First[$i1][$i2] = $Second[$4][$i2]
 Next
 $4 += 1
Next
_ArrayDisplay($First)

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  
Followers 0