Jump to content
Sign in to follow this  
mentosan

read a specific line

Recommended Posts

mentosan

Hi

I want to read the second line from a txt file and then to use it in a script.

Please help

Share this post


Link to post
Share on other sites
saywell

Hi

I want to read the second line from a txt file and then to use it in a script.

Please help

At last i can repay some debt by answering a question instead of asking! And i won't get sarky and say RTFM!

FileReadLine ( filehandle or "filename" [, line] ) is the function you need.

William

Share this post


Link to post
Share on other sites
Andreik

Hi

I want to read the second line from a txt file and then to use it in a script.

Please help

Or like in this example:

#Include <File.au3>
$PATH = FileOpenDialog("SELECT",@ScriptDir,"All (*.*)",1)
Dim $LINE
_FileReadToArray($PATH,$LINE)
If IsArray($LINE) And $LINE[0] >= 2 Then MsgBox(0,"LINE 2",$LINE[2])

When the words fail... music speaks

Share this post


Link to post
Share on other sites
crazyjts

How do I read the second to last line of a file with an unknown number of lines?

FileReadLine will read the last line with a line number = -1 but I can't figure out how to read the line previous to that.

Share this post


Link to post
Share on other sites
AdmiralAlkex

You could use _FileCountLines() to check how many lines there are and reduce that number by 1 and FileReadLine() it, or use UBound() if using Andreik's example

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  

×