Jump to content
Sign in to follow this  
kickitship

how do i read a random line of text from a file?

Recommended Posts

kickitship

the question is how do i read a random line of text from a file? should be easy enough to do, thanks in advance

Share this post


Link to post
Share on other sites
electrico

Open file with notepad++.

See how much lines it contains.

For example, there is 888 lines.

Then

$handle = FileOpen("C:\example.txt")
$info = FileReadLine($handle, Random(1,888,1))
MsgBox (0, "Random line:", $info)

Edited by electrico

Share this post


Link to post
Share on other sites
Spiff59

And just to confuse you, another route...

#include <File.au3>
Global $aLines
_FileReadToArray(@ScriptDir & "\test.txt", $aLines)
$Line = $aLines[Random(1, $aLines[0])]
MsgBox(1,"", $Line)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.