jugador Posted July 14, 2021 Share Posted July 14, 2021 (edited) > 1D to 2D Array #include<array.au3> Local $o_Eg1[] = ['A','1','111','B','2','222','C','3','333','D','4' ] _ArrayDisplay( __1Dto2DArray($o_Eg1, 3) ) Local $o_Eg2[] = ['A','1','B','2','C','3','D','4','E','5' ] _ArrayDisplay( __1Dto2DArray($o_Eg2, 2) ) ; #FUNCTION# ============================================================================= ; Name...........: __1Dto2DArray ; ========================================================================================= Func __1Dto2DArray($0_Array, $0_mod = 2) If UBound($0_Array, 2) > 1 Then Return SetError(1) Local $o_Array[Ceiling(UBound($0_Array) / $0_mod)][$0_mod] For $i = 0 To UBound($0_Array) - 1 $o_Array[Floor($i / $0_mod)][Mod($i, $0_mod)] = $0_Array[$i] Next Return $o_Array EndFunc Edited July 17, 2021 by jugador dmob 1 Link to comment Share on other sites More sharing options...
dmob Posted July 15, 2021 Share Posted July 15, 2021 Sweet, like a turbo StringSplit thanks for sharing. jugador 1 Link to comment Share on other sites More sharing options...
jugador Posted July 17, 2021 Author Share Posted July 17, 2021 (edited) > 2D to 1D Array #include <array.au3> Local $fillArray_B[6][] = [['A', 1], ['B', 2], ['C', 3], ['D', 4], ['E', 5], ['F', 6]] _ArrayDisplay($fillArray_B) _ArrayDisplay( __2Dto1DArray($fillArray_B) ) _ArrayDisplay( __2Dto1DArray($fillArray_B, False) ) Local $fillArray_C[6][] = [['A', 1, 'AAA'], ['B', 2, 'BBB'], ['C', 3, 'CCC'], ['D', 4, 'DDD'], ['E', 5, 'EEE'], ['F', 6, 'FFF']] _ArrayDisplay($fillArray_C) _ArrayDisplay( __2Dto1DArray($fillArray_C) ) _ArrayDisplay( __2Dto1DArray($fillArray_C, False) ) ; #FUNCTION# ============================================================================= ; Name...........: __2Dto1DArray ; ========================================================================================= Func __2Dto1DArray($0_Array, $0_byRow = True) If UBound($0_Array, 2) < 1 Then Return SetError(1) Local $o_1DArray[UBound($0_Array) * UBound($0_Array, 2)] Local $o_Flag = ($0_byRow ? UBound($0_Array) : UBound($0_Array, 2)) For $i = 0 To UBound($0_Array) - 1 For $k = 0 To UBound($0_Array, 2) - 1 If $0_byRow Then $o_1DArray[($o_Flag * $k) + $i] = $0_Array[$i][$k] Else $o_1DArray[($o_Flag * $i) + $k] = $0_Array[$i][$k] Endif Next Next Return $o_1DArray EndFunc As my coding knowledge limit to basic stuff so its end over here. Now back to asking mode . Edited July 17, 2021 by jugador Link to comment Share on other sites More sharing options...
Gianni Posted July 17, 2021 Share Posted July 17, 2021 please @jugador, do me a favor, rename those functions to __2Dto1DArray and __1Dto2DArray instead of using "multidimensional" ..... jugador 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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