Loop, Read, InputFile ignores last line in file when empty

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hotkeyguy
Posts: 170
Joined: 11 Oct 2014, 12:22

Loop, Read, InputFile ignores last line in file when empty

11 Nov 2019, 13:21

Hello,

yep, any way to avoid that? In my case that's a significant difference (files are not equal):

Code: Select all

1
2
2 lines vs. 3 lines:

Code: Select all

1
2


Many thanks and greetings
hotkeyguy
User avatar
boiler
Posts: 16951
Joined: 21 Dec 2014, 02:44

Re: Loop, Read, InputFile ignores last line in file when empty

11 Nov 2019, 14:07

You can read the file into a variable and parse the text directly, like this:

Code: Select all

FileRead, Text, MyFile.txt
Loop, Parse, Text, `n, `r
	TextOut .= "Line " A_Index " is: " A_LoopField "`n"
MsgBox, % TextOut

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww and 434 guests