Jump to content

Recommended Posts

Posted

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 :)

Posted

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

Posted

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 (edited)

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
Posted

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

Posted

Ha sorry I know I clicked edit and fixed the mode thing. Anyways if you still haven't realized it by now the line

$lines = _FileCountLines($sFile)

should be

$lines = _FileCountLines($sFile, 0)

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
×
×
  • Create New...