RickB75 Posted April 4, 2016 Share Posted April 4, 2016 I'm drawing a blank here. I know how to do this overly simple thing but for the life of me, I can't get it to work correctly. I want to create a 2d array and then do a loop and using _arrayadd, add data to it in the correct columns. My example script #include <Array.au3> Local $aBlank[1][1] For $i = 0 To 10 -1 $colzero = "aa"& $i $colone = "bb" & $i _ArrayAdd($aBlank,$colzero) _ArrayAdd($aBlank,$colone,1) Next _ArrayDisplay($aBlank) Why can't I get the 2nd Arrayadd to work correctly??? I know this is something simple that I'm overlooking but right now I can't see the forest for the trees Link to comment Share on other sites More sharing options...
InunoTaishou Posted April 4, 2016 Share Posted April 4, 2016 (edited) _ArrayAdd is just going to add another row to a 2d array. Looking at the parameters you can add values to the columns using a delimiter in the $sValue parameter. Quote _ArrayAdd ( ByRef $aArray, $vValue [, $iStart = 0 [, $sDelim_Item = "|" [, $sDelim_Row = @CRLF [, $iForce = $ARRAYFILL_FORCE_DEFAULT]]]] ) #include <Array.au3> Local $aBlank[1][2] For $i = 0 To 10 - 1 Local $sValue = "aa" & $i & "|" & "bb" & $i _ArrayAdd($aBlank, $sValue) Next _ArrayDisplay($aBlank) Also, the main reason why yours didn't add to the column is because you declared the array with only 1 column. Edited April 4, 2016 by InunoTaishou Link to comment Share on other sites More sharing options...
RickB75 Posted April 5, 2016 Author Share Posted April 5, 2016 Bingo!!! Thank you @InunoTaishou for your help. Thats exactly what I was looking for. Great explanation also. I was thinking [0][0] was to start at zero in both columns. I completly forgot that [1] was telling it where to start at in the array and [2] is how many columns I want. Thank you!!!! 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