ur Posted April 10, 2017 Posted April 10, 2017 I have a string with comma seperated as below. Name="Test-win10x64,Test-win10x65,Test-win10x67" $machine_names = StringSplit($tempINIValue, ',', $STR_ENTIRESPLIT) with the above line i can get a single dimension array. But I want a tabular format array like 4X4 where I want to add the 4 single dimension arrays as different columns in them. Is there any option to do the same.
Floops Posted April 10, 2017 Posted April 10, 2017 Since you said 4X4 I added another entry to your string. Try the following code, is that what you want? #include <Array.au3> $tempINIValue = "Test-win10x64,Test-win10x65,Test-win10x67,Test-win10x68" $machine_names = StringSplit($tempINIValue, ',', $STR_ENTIRESPLIT) Global $aTable[4][4] For $i = 0 to UBound($aTable, 1) - 1 $aTable[0][$i] = $machine_names[$i+1] Next _ArrayDisplay($aTable) If not please elaborate further
Subz Posted April 10, 2017 Posted April 10, 2017 Or #include <Array.au3> $tempINIValue = "Test-win10x64,Test-win10x65,Test-win10x67,Test-win10x68" $machine_names = StringSplit($tempINIValue, ',', 3) _ArrayTranspose($machine_names) _ArrayDisplay($machine_names)
Malkey Posted April 10, 2017 Posted April 10, 2017 Maybe this. #include <Array.au3> Local $sName="Test-win10x64,Test-win10x65,Test-win10x67,Test-win10x69" ;Arrays Local $machine_names = StringSplit($sName, ',', 2) ; $STR_NOCOUNT (2) Local $aItem1 = ["A", "B", "C", "D"] Local $aItem2 = [1, 2, 3, 4] Local $aItem3 = ["up", "down", "left", "right"] Local $Arrays = [$machine_names, $aItem1, $aItem2, $aItem3] ; Array of array names. $aCombined2D = _Arrayombine($Arrays) _ArrayDisplay($aCombined2D) Func _Arrayombine($Arrays) Local $iRows = UBound($Arrays[0], 1), $iCols = UBound($Arrays) Local $a[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $a[$i][$j] = ($Arrays[$j])[$i] Next Next Return $a EndFunc ;==>_Arrayombine
Floops Posted April 10, 2017 Posted April 10, 2017 11 minutes ago, Subz said: Or #include <Array.au3> $tempINIValue = "Test-win10x64,Test-win10x65,Test-win10x67,Test-win10x68" $machine_names = StringSplit($tempINIValue, ',', 3) _ArrayTranspose($machine_names) _ArrayDisplay($machine_names) I didn't even know this function exists. The more you know
czardas Posted April 11, 2017 Posted April 11, 2017 (edited) You could also try my _ArrayAttach() function from ArrayWorkshop.au3 (see my signature below) #include <ArrayWorkshop.au3> Local $array1 = [1,2,3] Local $array2 = [4,5,6] _ArrayAttach($array1, $array2, 2) ; attach columns (i.e. 2nd dimension) Edited April 11, 2017 by czardas operator64 ArrayWorkshop
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