gcue Posted September 9, 2008 Share Posted September 9, 2008 is this possible? i looked into _Arrayconcatenate _ArrayInsert _ArrayAdd and they all add by rows =/ im trying to merge two arrays by column Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 9, 2008 Share Posted September 9, 2008 Could you give us an example of what you mean? Like say I have two arrays [[a,b],[c,d]] and [[e,f],[g,h]] What would they look like afterwards? Link to comment Share on other sites More sharing options...
gcue Posted September 9, 2008 Author Share Posted September 9, 2008 sure... array1 [0] 5 [1] serial1 [2] serial2 [3] serial3 [4] serial4 [5] serial5 array2 [0] 5 [1] registrypath1 [2] registrypath2 [3] registrypath3 [4] registrypath4 [5] registrypath5 id like to see the final array as [0] 5 [1] registrypath1 serial1 [2] registrypath2 serial2 [3] registrypath3 serial3 [4] registrypath4 serial4 [5] registrypath5 serial5 Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 9, 2008 Share Posted September 9, 2008 Ah. So you are looking for a side by side kinda thing. Hmm... One way you could do this is Dim $array1[] = [5, "s1", "s2", "s3", "s4", "s5"] Dim $array2[] = [5, "r1", "r2", "r3", "r4", "r5"] Dim $arraymerge[] = [3, $array1, $array2] For $a = 1 To $arraymerge[0] MsgBox(0, "", $arraymerge[0][$a] & " " & $arraymerge[1][$a]) Next Note, this is untested but I believe it would work. I know the [0][$a] is a little backwards from normal thinking, but it does create a single array without much mess. Link to comment Share on other sites More sharing options...
trancexx Posted September 9, 2008 Share Posted September 9, 2008 Ah. So you are looking for a side by side kinda thing. Hmm... One way you could do this is Dim $array1[] = [5, "s1", "s2", "s3", "s4", "s5"] Dim $array2[] = [5, "r1", "r2", "r3", "r4", "r5"] Dim $arraymerge[] = [3, $array1, $array2] For $a = 1 To $arraymerge[0] MsgBox(0, "", $arraymerge[0][$a] & " " & $arraymerge[1][$a]) NextoÝ÷ ØÚ-zØb²+.׬µç[ºÒzX½èÂ¥w +'£a{M7騬jX¶WiÉ0j·l~º&æj[ay"î¶+]¡ëæy«" ^jºÚËç!ë,þ«¨µãh×hzÉ÷öÓ^Áªëk'·æyÙbëaǯzx¢¸ v¥jºÚÊÆ«yØ}êÞا²,Þjëh×6Dim $array1[7] = [6, 'serial1', 'serial2', 'serial3', 'serial4', 'serial5', 'serial6'] Dim $array2[6] = [5, 'registrypath1', 'registrypath2', 'registrypath3', 'registrypath4', 'registrypath5'] $size = UBound($array1) If $size < UBound($array2) Then $size = UBound($array2) ReDim $array1[$size] ElseIf $size > UBound($array2) Then ReDim $array2[$size] EndIf Dim $array3[$size] $array3[0] = UBound($array3) - 1 For $i = 1 To $size - 1 $array3[$i] = $array2[$i] & " " & $array1[$i] Next For $element In $array3 MsgBox(0, '', $element) Next It is even easier for arrays with same size ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
gcue Posted September 9, 2008 Author Share Posted September 9, 2008 hey trance.. looks good but it adds the second value to the same column Link to comment Share on other sites More sharing options...
youknowwho4eva Posted September 9, 2008 Share Posted September 9, 2008 (edited) wouldn't for $n=1 to $array1[0] step +1 $array3[$n] = $array1[$n] & $array2[$n] next do the trick? Edited September 9, 2008 by youknowwho4eva Giggity Link to comment Share on other sites More sharing options...
trancexx Posted September 9, 2008 Share Posted September 9, 2008 hey trance.. looks good but it adds the second value to the same columnactually, it doesn't, there is 'nothing' and then 'space' and then '$array1[6]' @ youknowwho4eva; that's the same code only stripped ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now