Jump to content
Sign in to follow this  

how not to read the first line of a txt file then display it then delete it and repeat?

Recommended Posts


i dont actually need to delete the line but im not good enough at creating arrays or anything to have it just go down the file and read 1 line at a time

the file is like this





and i need to FileReadLine ("names.txt",1)

and have it cycle through the list.

the only way i have been able to get it is to fileread remove first line file delete then filewrite.

but then everytime its out i have to go copy my text file back and start it over.

Edited by supadodger

Share this post

Link to post
Share on other sites

#Include <File.au3>
_FileReadtoArray(@SciptDir & "\file.txt",$Array)
For $N = 1 To $Array[0]

This will display a message box, and show the contents of each line of your file... Line by Line.

Array's are really awesome once you learn to use them, focus on that a bit more, and it will broaden your ability to program better. :D

Optionally to skip the first line, change "For $N = 1 To"... To "For $N = 2 To..."

Edited by BinaryBrother

Share this post

Link to post
Share on other sites

i figured id rather randomize and figured it out myself

heres wjhat i came up with.

$maclist = FileRead ("macs.txt")
$macalmost = StringSplit($maclist, @CRLF)
While 1
    $z1 = Random(1, 200,1)
$macread = $macalmost[$z1]
ClipPut ($macread)
msgbox (0,"",$macread)

Share this post

Link to post
Share on other sites

StringSplit($maclist, @CRLF) will work in most situations but not all. Some files don't use @CR (html for example) so you are better off to either use _FileReadToArray() [prefered] or

$macList = StringStripCR(FileRead("macs.txt"))
$macalmost = StringSplit($maclist, @LF)


Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver: - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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