Jump to content

Recommended Posts

Posted (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 by webxt
Posted

You don't even have a $comment variable declared. Are you trying to grab a random line from this text file?

Posted (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 by webxt
Posted

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.

Posted (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 by webxt
Posted

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
Posted (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 by webxt

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
  • Recently Browsing   0 members

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