Reading a certain line of a textfile

Get help with using AutoHotkey and its commands and hotkeys
Billykid
Posts: 43
Joined: 16 Sep 2019, 08:59

Reading a certain line of a textfile

24 Sep 2019, 10:23

Hi,
I just want to read a certain line of a given textfile.

Code: Select all

File := FileOpen("Test.txt", 0x0)  
strText := File.Read()                               ; works
textline10 := File.ReadLine(10)                  ; read line 10 - doesn't work
FileReadLine, textline11, "Test.txt", 11      ; read line 11 - doesnt work
What did I do wrong?
Thanks for your help.
User avatar
boiler
Posts: 9195
Joined: 21 Dec 2014, 02:44

Re: Reading a certain line of a textfile

24 Sep 2019, 10:44

File.ReadLine() reads a line of text from the current file pointer position. It doesn't provide for specifying which line.

No quotes around file name when using FileReadLine. Also make sure the text file is in the same folder as the script unless you provide a full path to the file (or proper relative file path).

Code: Select all

FileReadLine, textline11, Test.txt, 11

Return to “Ask For Help”

Who is online

Users browsing this forum: dpfbin2, hoppfrosch, Rohwedder, teadrinker, william_ahk and 46 guests