burger Posted January 26, 2008 Share Posted January 26, 2008 I getting an error message regarding this line of code: $line &= $aTableData1[$i][$j]I believe it is because I trying to delare a single dimensional array as a 2 dimensional array, but I'm over my head here if someone can please help me out.expandcollapse popup#include <IE.au3> #include <Array.au3> #include <File.au3> Dim $book1 If Not _FileCreate("book1.txt") Then MsgBox(4096, "Error", " Error Creating/book1.txt. error:" & @error) EndIf $sentlistfile = FileOpen("book1.txt", 1) ; Check if file opened for writing OK If $book1= -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $sURL = "http://finance.google.com/finance/historical?q=INDEXDJX:.BKTLA" $oIE = _IECreate($sURL,0,0) ;$oTable = _IETableGetCollection ($oIE, 0) $oTable1 = _IETableGetCollection ($oIE, 1) ;$aTableData = _IETableWriteToArray ($oTable) $aTableData1 = _IETableWriteToArray ($oTable1, True) ;_ArrayDisplay($aTableData, "_ArrayDisplay() Test1") _ArrayDisplay($aTableData1 , "_ArrayDisplay() Test2") Local $i = 0, $j = 0, $line Local $iMax = Ubound($aTableData1, 0) - 1, $jMax = Ubound($aTableData1, 1) - 1 For $i = 0 To $iMax $line = "" For $j = 0 to $jMax $line &= $aTableData1[$i][$j] If $j = $jMax Then FileWriteLine("book1.txt", $line) Else $line &= "," EndIf Next Next Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 this line: Local $iMax = Ubound($aTableData1, 0) - 1, $jMax = Ubound($aTableData1, 1) - 1should be : Local $iMax = UBound($aTableData1, 1) - 1, $jMax = UBound($aTableData1, 2) - 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
burger Posted January 26, 2008 Author Share Posted January 26, 2008 this line: Local $iMax = Ubound($aTableData1, 0) - 1, $jMax = Ubound($aTableData1, 1) - 1should be : Local $iMax = UBound($aTableData1, 1) - 1, $jMax = UBound($aTableData1, 2) - 1 Thanks Jos. That worked, but it wrote only the first line of the array to the file. Any idea how I can get all of the lines written? Link to comment Share on other sites More sharing options...
sherkas Posted January 26, 2008 Share Posted January 26, 2008 If $j = $jMax Then FileWriteLine("book1.txt", $line) Else $line &= "," EndIfYou statement is wrong. If $j = $jMax Then should be: If $j == $jMax Then Link to comment Share on other sites More sharing options...
burger Posted January 26, 2008 Author Share Posted January 26, 2008 (edited) thanks but that didn't change the output. Edit: Problem solved: Local $iMax = Ubound($aTableData1) Thanks again for the help. Edited January 26, 2008 by burger Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 26, 2008 Share Posted January 26, 2008 You statement is wrong. If $j = $jMax Then should be: If $j == $jMax Then Both are integers and the "==" operator is only for case sensitive string compares. I substituted adding $line to a message for writing to a file, but this gets the results I think are desired: Global $aTableData1[3][3] = [[0, 1, 2], ["a", "b", "c"], ["alpha", "beta", "gamma"]] Global $line Global $sMsg = "" For $i = 0 To UBound($aTableData1) - 1 $line = "" For $j = 0 to UBound($aTableData1, 2) - 1 $line &= $aTableData1[$i][$j] & "," Next $sMsg &= StringTrimRight($line, 1) & @CRLF Next MsgBox(64, "Results", $sMsg) Notice there is no need for $iMax or $jMax, the functionality of a For/Next loop takes care of that for you, with the Ubound() results used directly. If the number of lines is not too large to collect in the $sMsg string (upto 100MB or so), you should consider collecting all the lines and writing once to the file, it will be much faster. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
burger Posted January 27, 2008 Author Share Posted January 27, 2008 Thank you for those suggestions. 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