sshrum Posted July 13, 2007 Posted July 13, 2007 (edited) I have a 2 dimension array that I want to copy but I only need the first dim. I tried $a1DimArray = $a2DimArray REDIM $a1DimArray[$a2DimArray[0][0]] ...hoping that the rest of the array would just be truncated off. I got back a single dimed array with the correct number of elements that were all blank. Is this possible or do I have to parse the 2 dim array and move the values into the 1 dim array? EDIT: Thinking about this some more I think I just have to parse the array...the first column I want is the 0 column of the second dimension... Edited July 13, 2007 by sshrum Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot'
xcal Posted July 13, 2007 Posted July 13, 2007 Like this? #include <array.au3> Dim $array[10][2] For $i = 0 To 9 For $x = 0 To 1 $array[$i][$x] = $i & ' ' & $x Next Next _ArrayDisplay($array) ReDim $array[10][1] _ArrayDisplay($array) How To Ask Questions The Smart Way
sshrum Posted July 13, 2007 Author Posted July 13, 2007 (edited) Yeah. That works. Still a 2 dimension array...just with a signle dimension aspect. Thanx EDIT: No joy. It still is structured like a 2-dim array so calls to it have to be in the format: $array[$i][0]. I was hoping that I could get away with $array[$i] but after thinking about it, I'm pretty sure it isn't possible. I'm trying to truncate a 2-dim into a 1 dim and that just isn't going to happen. What you did is truncate all but the first row of the second dim...but it's still a 2 dim array. Nice try though. Edited July 13, 2007 by sshrum Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot'
xcal Posted July 13, 2007 Posted July 13, 2007 #include <array.au3> Dim $array[10][2] For $i = 0 To 9 For $x = 0 To 1 $array[$i][$x] = $i & ' ' & $x Next Next _ArrayDisplay($array) Dim $tmp For $i = 0 To 9 $tmp &= $array[$i][0] & '|' Next $newarray = StringSplit(StringTrimRight($tmp, 1), '|') _ArrayDisplay($newarray) How To Ask Questions The Smart Way
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