Jump to content

Read external files


 Share

Recommended Posts

#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 by webxt
Link to comment
Share on other sites

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 by webxt
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...