Function Reference


_ArrayTranspose

Transposes a 1D or 2D array (swaps rows and columns)

#include <Array.au3>
_ArrayTranspose ( ByRef $aArray [, $bForce1D = False] )

Parameters

$aArray Array to modify
$bForce1D [optional] Force single column 2D array into 1D - True/False (default)

Return Value

Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - $aArray is not a 1D or 2D array
2 - $aArray is not an array
3 - Invalid $bForce1D

Remarks

When the $bForce1D parameter is used, a transposed 2D array which has only a single column is forced into a 1D array with the same number of rows. In all other cases it is ignored.

Related

_ArraySwap

Example

#include <Array.au3>

Local $aArray[3][2] = [[1, 2], [3, 4], [5, 6]]
_ArrayDisplay($aArray, "Original")
_ArrayTranspose($aArray)
_ArrayDisplay($aArray, "Transposed")

Local $aArray[5] = [1, 2, 3, 4, 5]
_ArrayDisplay($aArray, "Original 1D")
_ArrayTranspose($aArray)
_ArrayDisplay($aArray, "Transposed to 2D")
_ArrayTranspose($aArray, Default)
_ArrayDisplay($aArray, "Re-transposed but still 2D")

Local $aArray[5] = [1, 2, 3, 4, 5]
_ArrayDisplay($aArray, "Original 1D")
_ArrayTranspose($aArray)
_ArrayDisplay($aArray, "Transposed to 2D")
_ArrayTranspose($aArray, True)
_ArrayDisplay($aArray, "Force re-transposed to 1D")