Sign in to follow this  
Followers 0
Daywap

Get random LINE from txt

21 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#Include <File.au3>
$sFile = "text.txt"
$lines = _FileCountLines($sFile)
$sFile = FileOpen($sFile)
$line = FileReadLine($sFile, Random(1, $lines, 1))
FileClose($sFile)

you should read the helpfile included with autoit : C:\Program Files\AutoIt3\AutoIt.chm

Why is it not working? I created text.txt but it gets me error in 4 line :)

Share this post


Link to post
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? :)

Share this post


Link to post
Share on other sites

You still don't have a mode.

$sFile = FileOpen($sFile, 0)

Look in the help file for required and optional parameters.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#11 ·  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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I don't get it ;)

What do you mean Manadar?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

My bad. THANK YOU VERY MUCH ;)

Share this post


Link to post
Share on other sites

I still don't get it.

;) it's a bug, right?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Lol yall are so bad though granted it was pretty blatant.

Share this post


Link to post
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
Sign in to follow this  
Followers 0