marko001 Posted October 14, 2010 Share Posted October 14, 2010 Hi, I have this code: dim $Global_Array[500][3] for $i = 0 to UBound(ID_Names)-1 [...] $Name_Search= _StringBetween($temp_file,'id="_units_','"',-1) $Number_Search =_StringBetween($filetrunk[0],'"place_unit_">',"<",-1) dim $Name_Number_Search[UBound($Name_Search)][3] for $k = 0 to UBound($Name_Search)-1 $Name_Number_Search[$k][0]=$ID_Names[$i][0] $Name_Number_Search[$k][1]=$Name_Search[$k] $Name_Number_Search[$k][2]=$Number_Search[$k] Next $Global_Array[$k][0] = $ArmyName_Number_Search[$k][0] $Global_Array[$k][1] = $ArmyName_Number_Search[$k][1] $Global_Array[$k][2] = $ArmyName_Number_Search[$k][2] Next _ArrayDisplay($Global_Array) I suppose adding datas to this array it doesn't work. What I need to do, since there is the "For $i" cycle that reset the vars, is to add the value found in the inner For cycle to a global 2D Array. I.E. $Global_Array[0][0] = $Name_Number_Search[0][0] $Global_Array[0][1] = $Name_Number_Search[0][1] $Global_Array[0][2] = $Name_Number_Search[0][2] and after first cycle $Global_Array[1][0] = $Name_Number_Search[0][0] $Global_Array[1][1] = $Name_Number_Search[0][1] $Global_Array[1][2] = $Name_Number_Search[0][2] and so on.. How can I do it? Thanks a lot, Marco Link to comment Share on other sites More sharing options...
trung0407 Posted October 14, 2010 Share Posted October 14, 2010 (edited) arrayAdd works on 1D array only, use something like $Global_Array[$k] = _ArrayAdd(...) It's not the best solution because it's not recommended to add arrays into array, so try to figure out a better solution Edited October 14, 2010 by trung0407 Link to comment Share on other sites More sharing options...
czardas Posted October 14, 2010 Share Posted October 14, 2010 (edited) I'm not quite sure what you are trying to do. If your array is too small to hold the data, you can resize it using ReDim. If you wish to have an array inside another array, instead add more dimensions, or alternatively you can represent arrays as strings with delimeters, which can later be expanded using StringSplit. Edited October 14, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
GEOSoft Posted October 14, 2010 Share Posted October 14, 2010 Both previous posts are correct. Nested Arrays are not a great idea, even though it can be done and there are indeed examples of it in the help file, they can be treacherous to work with and invariably require extra checking in the script. ReDim is too slow so I don't recommend that method at all. Delimited strings fit the bill but, if you have your data already in an array, don't loop it to create an array. Simply use _ArrayToString() and make sure the specified delimiter is not the same as the delimiter you are using for your main array. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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