Jump to content

Get random LINE from txt


Daywap
 Share

Recommended Posts

Hi, I am creating script that would get random line from txt and make it to be inputed somewhere. How to do it? I am currently have this ;)

$file = FileOpen("test.txt", 0)
$i = Random(1, 99999999, 1)

Random(line)

FileClose($file)

I know this sounds stupid, but please how to get random line? Thank you very much :)

Link to comment
Share on other sites

Hi, I am creating script that would get random line from txt and make it to be inputed somewhere. How to do it? I am currently have this ;)

$file = FileOpen("test.txt", 0)
$i = Random(1, 99999999, 1)

Random(line)

FileClose($file)

I know this sounds stupid, but please how to get random line? Thank you very much :)

Hi,

although i don't believe you have an text file with 99999999 lines and it's hopefully not written by Bruce Forte:

$file = FileOpen("test.txt", 0)
$i = Random(1, 99999999, 1)
MsgBox (0, "Line " & $i, $line = FileReadLine ($file, $i))
FileClose($file)

;-))

Stefan

Link to comment
Share on other sites

My bad ;P. Okay, that's what I added. But it still not work I get error in 6 Line.

#Include <File.au3>
#Include <FF.au3>

$sFile = "text.txt"
$lines = _FileCountLines($sFile)
$sFile = FileOpen($sFile)
$line = FileReadLine($sFile, Random(1, $lines, 1))
FileClose($sFile)

_FFPrefSet("general.useragent.override", String($line))

Can you help me? :)

Link to comment
Share on other sites

My bad ;P. Okay, that's what I added. But it still not work I get error in 6 Line.

#Include <File.au3>
#Include <FF.au3>

$sFile = "text.txt"
$lines = _FileCountLines($sFile)
$sFile = FileOpen($sFile)
$line = FileReadLine($sFile, Random(1, $lines, 1))
FileClose($sFile)

_FFPrefSet("general.useragent.override", String($line))

Can you help me? :)

put your mouse on fileOpen, and press F1. Edited by RagsRevenge
Link to comment
Share on other sites

My bad ;P. Okay, that's what I added. But it still not work I get error in 6 Line.

#Include <File.au3>
#Include <FF.au3>

$sFile = "text.txt"
$lines = _FileCountLines($sFile)
$sFile = FileOpen($sFile)
$line = FileReadLine($sFile, Random(1, $lines, 1))
FileClose($sFile)

_FFPrefSet("general.useragent.override", String($line))

Can you help me? ;)

Posted Image

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...