Jury Posted September 13, 2009 Share Posted September 13, 2009 Please - what's wrong here - I copied these two parts from the examples but it doesn't work. I get this error: C:\Program Files\AutoIt3\Examples\InetGet_ju.au3 (25) : ==> Expected a "=" operator in assignment statement.: $array[$x] = StringRegExp($line, 'HTML', 2) $array^ ERROR ----------------------------------------- $file = FileOpen("C:\foo.html", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $x = 1 While 1 $line = FileReadLine($file) $x += 1 If @error = -1 Then ExitLoop $array[$x] = StringRegExp($line, 'HTML', 2) ;MsgBox(0, "Line read:", $line) Wend FileClose($file) for $i = 0 to UBound($array) - 1 msgbox(0, "RegExp Test with Option 2 - " & $i, $array[$i]) Next ------------------------------------ Thanks for any pointers, Jury Link to comment Share on other sites More sharing options...
Hawkwing Posted September 13, 2009 Share Posted September 13, 2009 (edited) You have to declare $array as an array at the start of your script. Please use codeboxes when displaying code (preferably autoit codeboxes). Edited September 13, 2009 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
Jury Posted September 13, 2009 Author Share Posted September 13, 2009 You have to declare $array as an array at the start of your script. Please use codeboxes when displaying code (preferably autoit codeboxes). Hawkwing, Thanks - can't find anything about codeboxes I'll try - now it compiles and ends with +>18:15:59 AutoIt3Wrapper Finished but still no msgbox appears. Dim $array[10] InetGet("http://www.publications.parliament.uk/pa/ld/ldjudgmt.htm", "C:\foo.html") $file = FileOpen("C:\foo.html", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $x = 1 While 1 $line = FileReadLine($file) $x += 1 If @error = -1 Then ExitLoop $array = StringRegExp($line, 'HTML', 2) ;MsgBox(0, "Line read:", $line) Wend for $i = 0 to UBound($array) - 1 msgbox(0, "RegExp Test with Option 2 - " & $i, $array[$i]) Next FileClose($file) Link to comment Share on other sites More sharing options...
Hawkwing Posted September 13, 2009 Share Posted September 13, 2009 Perhaps that example was for a previous version, it doesn't seem to be getting to the while loop.btw, it used to be that you had to use to have a scrolling codebox, but I guess does that now. You can use [autoit][/autoit] to have the code colored like it is in SciTE, making it much easier to read. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 13, 2009 Developers Share Posted September 13, 2009 This line will override the Array each time a record is read, so that means you will only get the result of the last record. $array = StringRegExp($line, 'HTML', 2) 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...
Hawkwing Posted September 13, 2009 Share Posted September 13, 2009 (edited) Perhaps that example was for a previous version, it doesn't seem to be getting to the while loop. Hmm, must have been something I did, it's working now. Try this #include<file.au3> Dim $array[_FileCountLines("C:\foo.html") + 1] InetGet("http://www.publications.parliament.uk/pa/ld/ldjudgmt.htm", "C:\foo.html") $file = FileOpen("C:\foo.html", 0) ;Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $x = 1 While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $array[$x] = StringRegExp($line, 'HTML', 2) $x += 1 Wend for $i = 0 to UBound($array) - 1 msgbox(0, "RegExp Test with Option 2 - " & $i, $array[$i]) Next FileClose($file) Edit: That's an autoit codebox, much easier to read (well, unless the code isn't autoit) Edited September 13, 2009 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
Jury Posted September 14, 2009 Author Share Posted September 14, 2009 Thanking you Hawkwing and Jos now it works, Cheers, jury 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