chachew Posted October 20, 2011 Share Posted October 20, 2011 I have an array that will populate data but i need to put "" around the data Example: Original array Dim $array[1][7] $array[0][0]=ControlListView("CallStatus","","TListView2","GetText",0,1) $array[0][1]=ControlListView("CallStatus","","TListView2","GetText",0,2) $array[0][2]=ControlListView("CallStatus","","TListView2","GetText",0,3) $array[0][3]=ControlListView("CallStatus","","TListView2","GetText",0,4) $array[0][4]=ControlListView("CallStatus","","TListView2","GetText",0,5) $array[0][5]=ControlListView("CallStatus","","TListView2","GetText",0,6) $array[0][6]=ControlListView("CallStatus","","TListView2","GetText",0,7) Can i add " " around each set of data in the array Link to comment Share on other sites More sharing options...
jchd Posted October 20, 2011 Share Posted October 20, 2011 (edited) It's unclear to me just why you want to enclose strings (I assume you populate it with strings) data in your array.If your usage if for producing a CSV line, you can use something like this:$csv = '"' & _ArrayToString($myArray, '","') & '"' Edited October 20, 2011 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
chachew Posted October 20, 2011 Author Share Posted October 20, 2011 It's unclear to me just why you want to enclose strings (I assume you populate it with strings) data in your array. If your usage if for producing a CSV line, you can use something like this: $csv = '"' & _ArrayToString($myArray, '","') & '"' Im reading infor from a ListView and then converting that to a string so i can have an html page display that data via javascript. Link to comment Share on other sites More sharing options...
Morthawt Posted October 20, 2011 Share Posted October 20, 2011 (edited) When ever you use two sets of " you will "escape" it and it will become a piece of text inside the variable. So $hello = """This is a test""" will look like "This is a test" because for a string to work it needs quotes of some kind like "text" but if you want quotes to be part of the data you double the quotes so you end up with 3 of them either side, the single first ones at the start and end define the begining and end of the variable whereas the next two on both side translate to one quote in the actual data. Either that or you can use a mixture of apostrophe and quotes like $hello = 'hello "this" part right there is a test' Since your string is defined using ' instead of " your " does not need to be "escaped" by doubling it up to have it show up in the data. If you wanted to use ' to define your string and also have ' as part of your text, you need to double it up as before $test = 'this is Brian''s seat' You could do something like $array[1] = '"' & $array[1] & '"' $array[1] = """" & $array[1] & """" which "should" do the same thing, first one is a single " encapsulated with a ' either side, the second is " either side with a double quote "" making it appear as part of the data. Edited October 20, 2011 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Malkey Posted October 20, 2011 Share Posted October 20, 2011 Here is a working example. Note the symbiotic relationship between the For - Next loop and the array. #include <Array.au3> WinActivate("Program Manager") WinWaitActive("Program Manager") Local $iNum = ControlListView("Program Manager", "", "", "GetItemCount") Local $array[$iNum][1] For $i = 0 To $iNum - 1 $array[$i][0] = '"' & ControlListView("Program Manager", "", "", "GetText", $i) & '"' Next _ArrayDisplay($array, "Desktop Items") Link to comment Share on other sites More sharing options...
chachew Posted October 21, 2011 Author Share Posted October 21, 2011 (edited) So how would i simultaneously use the For loop to get row and column, i used you example and i can get the rows no problem #include <Array.au3> Local $iRow = ControlListView("CallStatus","",3, "GetItemCount") Local $iCol = "7" Local $array[$iRow][$iCol] For $i = 0 To $iRow - 1 $array[$i][0] = '"' & ControlListView("CallStatus","",3, "GetText", $i) & '"' Next _ArrayDisplay($array,"Test") But if i also try to get the columns...its not working..my thinking is obviously wrong #include <Array.au3> Local $iRow = ControlListView("CallStatus","",3, "GetItemCount") Local $iCol = "7" Local $array[$iRow][1] For $i = 0 To $iRow - 1 $array[$i][0] = '"' & ControlListView("CallStatus","",3, "GetText", $i) & '"' Next Local $iCol = ControlListView("CallStatus","",3, "GetSubItemCount") For $i2 = 0 To $iCol - 1 $array[$i][$i2] = '"' & ControlListView("CallStatus","",3, "GetText", $i2) & '"' Next _ArrayDisplay($array,"Test") Edited October 21, 2011 by chachew Link to comment Share on other sites More sharing options...
Malkey Posted October 21, 2011 Share Posted October 21, 2011 Here is an example of the commonly used method to fill a 2D array using two For - Next loops. #include <Array.au3> Local $sWinTitle = @ProgramFilesDir & "\AutoIt3" Run("Explorer.exe /e," & $sWinTitle) WinWaitActive($sWinTitle) Local $iNum = ControlListView($sWinTitle, "", "SysListView321", "GetItemCount") Local $array[$iNum][3] For $r = 0 To $iNum - 1 ; On each row For $c = 0 To UBound($array, 2) - 1 ; Enter each and every column, $c, on the row, $r. $array[$r][$c] = ControlListView($sWinTitle, "", "SysListView321", "GetText", $r, $c) Next Next _ArrayDisplay($array) If WinExists($sWinTitle) Then WinClose($sWinTitle) ; Close Windows Explorer Link to comment Share on other sites More sharing options...
chachew Posted October 21, 2011 Author Share Posted October 21, 2011 Perfect Malkey, that was exactly what i was looking for Link to comment Share on other sites More sharing options...
chachew Posted October 21, 2011 Author Share Posted October 21, 2011 (edited) I had this working now its broken for some reason...reads the row and column count but pulls no text?? #include <Array.au3> $str1='{ "callqueue": [' $str2='] }' ;~ While ProcessExists("CallStatus.exe") Local $iRow = ControlListView("CallStatus","",3, "GetItemCount") Local $iCol = ControlListView("CallStatus","",3, "GetSubItemCount") Local $array[$iRow][$iCol] For $r = 0 To $iRow - 1 For $c = 0 To UBound($array, 2) - 1 ; Enter each and every column, $c, on the row, $r. $array[$r][$c] = ControlListView("CallStatus","",3,"GetText", $r, $c) Next Next _ArrayDisplay($array,"Test") ;~ WEnd The CallStatus i'm reading from attachedCallStatus.exe Edited October 21, 2011 by chachew 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