Jump to content

merging two array


ddeerr
 Share

Recommended Posts

  • Developers

maybe i can make an array add on the first array with each value of the second :lmao:

i'll beginning this :ph34r:

Maybe post what you already have?

Adding 2 arrays should be pretty easy to do...

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

Maybe post what you already have?

Adding 2 arrays should be pretty easy to do...

Here is the wanted code section :

; this getting is for getting floders thru regedit without knowing were the path beginning

$tempHistoArray = recupereClefs($a)     ; this function return a 1 dimension array with random total size
$histoArrayS = $tempHistoArray
ControlSend($wh, "", 1, "{RIGHT}")
$aTemp = ControlGetText($wh, "", 3)
$aTemp = StringTrimLeft($aTemp, $cNomRepRegistre)   ; i get a string representing a regedit path

If $aTemp = $a Or StringInStr($aTemp, $a, 1) <> 0 Then      ; $a is the first path i get in my programm beginning ( 600 lines :\ )
    ControlSend($wh, "", 1, "{RIGHT}")
    $aTemp = ControlGetText($wh, "", 3)
    $aTemp = StringTrimLeft($aTemp, $cNomRepRegistre)
    If $aTemp <> $a And StringInStr($aTemp, $a, 1) <> 0 Then
        $tempHistoArray = recupereClefs($tempa)
        
        ; here i need to merge datas from $tempsHistoArray with $histoArrayS
        
    EndIf
EndIf
Link to comment
Share on other sites

  • Developers

example on adding 2 arrays:

#include<array.au3>
Dim $array1[5] = [1, 2, 3, 4, 5]
Dim $array2[5] = [6, 7, 8, 9, 10]
; add Array2 to Array1
ReDim $array1[UBound($array1) + UBound($array2) ]
For $x = 0 To UBound($array2) - 1
    $array1[UBound($array1) - UBound($array2) + $x] = $array2[$x]
Next
_ArrayDisplay($array1, "test")
Edited by JdeB

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

example on adding 2 arrays:

#include<array.au3>
Dim $array1[5] = [1, 2, 3, 4, 5]
Dim $array2[5] = [6, 7, 8, 9, 10]
; add Array2 to Array1
ReDim $array1[UBound($array1) + UBound($array2) ]
For $x = 0 To UBound($array2) - 1
    $array1[UBound($array1) - UBound($array2) + $x] = $array2[$x]
Next
_ArrayDisplay($array1, "test")oÝ÷ Ûú®¢×­Æ'hm¶§Ú+x8¦¶h¶­nëbv­)¶¬jëh×6
#include<array.au3>
Dim $array1[5] = [1, 2, 3, 4, 5]
Dim $array2[5] = [6, 7, 8, 9, 10]
; add Array2 to Array1
For $x = 0 To UBound($array2) - 1
    _ArrayAdd($array1, $array2[$x])
Next
_ArrayDisplay($array1, "test")

I was asking for time performance in code execution, maybe your one is much faster ?

Link to comment
Share on other sites

  • Developers

tx i don't think to reDim to do that but i do it like this :

#include<array.au3>
Dim $array1[5] = [1, 2, 3, 4, 5]
Dim $array2[5] = [6, 7, 8, 9, 10]
; add Array2 to Array1
For $x = 0 To UBound($array2) - 1
    _ArrayAdd($array1, $array2[$x])
Next
_ArrayDisplay($array1, "test")

I was asking for time performance in code execution, maybe your one is much faster ?

Both ways will work.

_ArrayAdd() will do a redim each time you add a record so depending on the sizes of the arrays, there could be a performance difference.

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...