Kharlog Posted December 10, 2005 Share Posted December 10, 2005 I have an array $array1 (0,1,2,3,4) and another array $array2 (5,6,7,8) and i need to add $array2 to $array1 so that $array1 would become (0,1,2,3,4,5,6,7,8). How to do that? I found function _ArrayAdd from the help file but I think it just puts the another array inside one array element so that $array1 would become (0,1,2,3,4,(5,6,7,8)). Am I right about that one? Link to comment Share on other sites More sharing options...
JerryD Posted December 10, 2005 Share Posted December 10, 2005 (edited) I have an array $array1 (0,1,2,3,4) and another array $array2 (5,6,7,8) and i need to add $array2 to $array1 so that $array1 would become (0,1,2,3,4,5,6,7,8). How to do that? I found function _ArrayAdd from the help file but I think it just puts the another array inside one array element so that $array1 would become (0,1,2,3,4,(5,6,7,8)). Am I right about that one?Try this: Dim $array1[5] Dim $array2[4] For $i = 0 to Ubound($array1)-1 $array1[$i] = $i Next For $i = 0 to Ubound($array2)-1 $array2[$i] = $i + 5 Next For $i = 0 to Ubound ( $array2 ) -1 Redim $array1[Ubound($array1)+1] $array1[Ubound($array1)-1] = $array2[$i] Next $Msg = '' For $i = 0 To UBound ( $array1 ) -1 $Msg = $Msg & $array1[$i] Next MsgBox ( 0, @ScriptName, $Msg ) Edited December 10, 2005 by JerryD Link to comment Share on other sites More sharing options...
randallc Posted December 10, 2005 Share Posted December 10, 2005 Hi,Or if you prefer (like me!) to use UDFs;;ArrayConcat.au3 ; 0_1#include<Array.au3>#include<Array2.au3>;http://www.autoitscript.com/forum/index.php?s=&showtopic=18211&view=findpost&p=125716;http://www.autoitscript.com/forum/index.php?act=Attach&type=post&id=5487$array1 =_StringSplit_B0("0,1,2,3,4",",")$array2 =_StringSplit_B0("5,6,7,8",","); Here it is....$array1 =_StringSplit_B0(_ArrayToString($array1,"|")&"|"&_ArrayToString($array2,"|"))_ArrayDisplay($array1,"$array1")Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Kharlog Posted December 11, 2005 Author Share Posted December 11, 2005 Thanks a lot, i got the point. 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