Deye Posted May 6, 2017 Posted May 6, 2017 (edited) Hi, the reason i need this : somewhere I read that _ArrayUnique() can crash the script when sending it through more then an 2D array in some cases it does I only need to create a 1D Array from column #4 . . . Edit: never mind should be something like this i guess .. Func _1D_ArrayFromColumn(ByRef $aArray, $iColumn = 0, $iCount = 1) Local $aArray1D = [UBound($aArray)] For $i = $iCount To UBound($aArray) - 1 _ArrayAdd($a1D, $iColumn) Next Return $aArray1D EndFunc ;==>_1D_ArrayFromColumn Edited May 6, 2017 by Deye
kylomas Posted May 6, 2017 Posted May 6, 2017 Deye, I don't think any distributed functions work on arrays with more than 2 dimensions. The following strips column #4 from a 10 column "2D" array... #include <array.au3> ; create and populate a 10 column 2D array Local $a2Darray[10][10] For $1 = 0 To UBound($a2Darray) - 1 For $2 = 0 To UBound($a2Darray, 2) - 1 $a2Darray[$2][$1] = StringFormat('%03i-%03i', $1, $2) Next Next _ArrayDisplay($a2Darray) ; create a 1D array from column #4 of the previous array Local $a1Darray[UBound($a2Darray)] For $1 = 0 To UBound($a2Darray) - 1 $a1Darray[$1] = $a2Darray[$1][3] Next _ArrayDisplay($a1Darray, 'Column 4 of 2D array') kylomas Deye 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
czardas Posted May 6, 2017 Posted May 6, 2017 Are you trying to create a unique column? operator64 ArrayWorkshop
czardas Posted May 6, 2017 Posted May 6, 2017 (edited) Ah okay! I thought perhaps you might want to create a 2D array only containing unique rows, and functions for that exist. These are two different things. Carry on! Edited May 6, 2017 by czardas Deye 1 operator64 ArrayWorkshop
kylomas Posted May 7, 2017 Posted May 7, 2017 @czardas - yes, before the code was added the request was crystal clear... Deye - the code you added and the code I posted do essentially the same thing (except that the array name in the array add is wrong). Is your question answered? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Deye Posted May 7, 2017 Author Posted May 7, 2017 kylomas, Yes & thanks I've used it over here Func __Array_FromColumn(ByRef $aArray, $iColumn = 0, $istart = 1) Local $aArray1D = [''] For $i = $istart To UBound($aArray) - 1 _ArrayAdd($aArray1D, $aArray[$i][$iColumn]) Next Return $aArray1D EndFunc ;==>__Array_FromColumn
mikell Posted May 7, 2017 Posted May 7, 2017 And what about _ArrayExtract($aArray, Default, Default, 3, 3)
czardas Posted May 7, 2017 Posted May 7, 2017 4 hours ago, kylomas said: @czardas - yes, before the code was added the request was crystal clear... Not to me. Extracting a column is not going to solve the crash issue. It could have been a work-around solution to a different problem, in which case further information might have proved useful. operator64 ArrayWorkshop
kylomas Posted May 7, 2017 Posted May 7, 2017 (edited) @Czardas - tongue in cheek.. Edited May 7, 2017 by kylomas czardas 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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