webxt Posted April 30, 2008 Posted April 30, 2008 Is it possible to read external file (for example www.mypage.com/news.txt) with AutoIT? Best Regards, webxt
webxt Posted April 30, 2008 Author Posted April 30, 2008 (edited) #include <INet.au3> $s_URL = "http://www.mypage.com/news.txt"; Dim $news[4] _INetGetSource ($s_URL) $old = -1 Do $temp = Random(1,4,1) Until $temp <> $old MsgBox(0, "Random news", $news[$temp]) news.txt conent $news[1] = "news 1" $news[2] = "news 2" $news[3] = "news 3" What's wrong on this script? Any help would be apreciated. Best Regards, webxt Edited April 30, 2008 by webxt
weaponx Posted April 30, 2008 Posted April 30, 2008 You don't even have a $comment variable declared. Are you trying to grab a random line from this text file?
webxt Posted April 30, 2008 Author Posted April 30, 2008 (edited) Yes, I tried to grab a random line from text file (if is it possible without add the "$news[x]...") #include <INet.au3> Dim $news[4] $news[1] = "news 1" $news[2] = "news 2" $news[3] = "news 3" $old = -1 Do $temp = Random(1,4,1) Until $temp <> $old MsgBox(0, "Random news", $news[$temp]) ^example that works Edited April 30, 2008 by webxt
James Posted April 30, 2008 Posted April 30, 2008 How does your file look? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
weaponx Posted April 30, 2008 Posted April 30, 2008 Well we don't know what your text file looks like, is each line comma seperated? Linefeed seperated? Regardless you are declaring $news array but the contents are actually in $s_URL.
webxt Posted April 30, 2008 Author Posted April 30, 2008 (edited) news.txt: $news[1] = "news 1" $news[2] = "news 2" $news[3] = "news 3" but would be greater news 1 news 2 news 3 Edited April 30, 2008 by webxt
weaponx Posted April 30, 2008 Posted April 30, 2008 In that case try: #include <INet.au3> $s_URL = "http://www.mypage.com/news.txt"; $original = _INetGetSource ($s_URL) $split = StringSplit($original, @CRLF) For $X = 1 to $split[0] ConsoleWrite("News item " & $X & ": " & $split[$X] & @CRLF) Next
webxt Posted April 30, 2008 Author Posted April 30, 2008 (edited) Thank you, Weaponx!A little thing: if I want to show only one random news than exit, what should I do?Best Regards,webxt Edited April 30, 2008 by webxt
weaponx Posted April 30, 2008 Posted April 30, 2008 $random = Random(1,$split[0],1) MsgBox(0,"",$split[$random])
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