asiawatcher Posted July 25, 2017 Posted July 25, 2017 (edited) i have this string 0,6,36,4,25,22,1,35,9,5,28,3,29,3,20,25,18,31,8,4,11 i know this example Example() Func Example() Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",") ; Split the string of days using the delimiter "," and the default flag value. #cs The array returned will contain the following values: $aDays[1] = "Mon" $aDays[2] = "Tues" $aDays[3] = "Wed" ... $aDays[7] = "Sun" #ce For $i = 1 To $aDays[0] ; Loop through the array returned by StringSplit to display the individual values. MsgBox($MB_SYSTEMMODAL, "", "$aDays[" & $i & "] - " & $aDays[$i]) Next EndFunc ;==>Example but i want to insert it into a 2d array in group[s of 2 like 0 - 6 36 - 4 25 - 22 1 - 35 etc.. without the - of course how do we do this ? cheers Edited July 25, 2017 by asiawatcher
water Posted July 25, 2017 Posted July 25, 2017 Always process two rows at once: For $i = 1 To $aDays[0] Step 2 ; Loop through the array returned by StringSplit to display the individual values. MsgBox($MB_SYSTEMMODAL, "", $aDays[$i] & " " & $aDays[$i + 1]) Next asiawatcher 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Danp2 Posted July 25, 2017 Posted July 25, 2017 Here a prior thread on the subject asiawatcher 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
Malkey Posted July 26, 2017 Posted July 26, 2017 Here is an example of a coma separate string to a two column 2D array. #include <Array.au3> Local $str = "0,6,36,4,25,22,1,35,9,5,28,3,29,3,20,25,18,31,8,4,11" $array = StringSplit($str, ",", 2) ; (2) = disable the return count in the first element. $aArray2D = _Array1DTo2D($array, 2) ; 2 parmeter for return 2 columns in 2A array. _ArrayDisplay($aArray2D) Func _Array1DTo2D(ByRef $aArray1D, $iNumberOfCols) Local $aRet[Ceiling(UBound($aArray1D) / $iNumberOfCols)][$iNumberOfCols] For $i = 0 To UBound($aArray1D) - 1 $aRet[Int($i / $iNumberOfCols)][Mod($i, $iNumberOfCols)] = $aArray1D[$i] Next Return $aRet EndFunc ;==>_Array1DTo2D
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