Jump to content

[Solved] Concatenating two column-based arrays

Recommended Posts

I'm having an issue concatenating two arrays together that are of the format $array[1][30].

For example the _ArrayDisplay of each looks like this:


How can I concatenate two of these together? 

_ArrayConcatenate($arrOut, $arrClient)
If @error Then
    MsgBox(0, "Error", @error)

This code is giving me Error 5, which states that there is a column mismatch. I'm guessing _ArrayConcatenate was made to be used with rows and not columns.

Anyone have any ideas on how to do this? Sorry if it's been asked before, but I searched and didn't find anything.

Edited by anthonyjr2


Link to post
Share on other sites

Sorry if I didn't explain it well enough,

I want them to be side by side. As in if the first array has 1 row,10 columns and the second has 1 row,5 columns, the final concatenated array would just have 1 row,15 columns.


Link to post
Share on other sites

You could Redim the largest array to account for the extra columns in the smallest array and use _ArrayColInsert in a loop to add them together or something like below. Will only work work with 1D array, I think

#include <Array.au3>

local $array1[1][10] = [[0]]
local $array2[1][30] = [[1]]

_ArrayConcatenate($array1, $array2)


Link to post
Share on other sites
17 minutes ago, anthonyjr2 said:

I'm not too worried about that, the array is never going to be more than 20-30 elements.

Worth pointing out because it might be relevant to someone in the future. Each transformation requires every element within the arrays to be overwritten. The solution is to write a function which adds the columns directly without first running twice around the block.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...