Loop parse on Unix (LF) file? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Loop parse on Unix (LF) file?

18 May 2019, 06:01

Why this doesn't work.
I am trying to edit a file that is using "Unix (LF)" but Loop,Parse displays nothing

FileRead and FileReadLine can output the line\text to a variable but Loop,Parse don't display anything no matter what delimiter I use
A_LoopField is always empty
User avatar
Cuadrix
Posts: 236
Joined: 07 May 2017, 08:26

Re: Loop parse on Unix (LF) file?

18 May 2019, 17:42

Code: Select all

;FileRead, file, unixfile.txt

;example unix text file
file =
(
One
Two
Three
Four
)

;example windows text file
;file := "One`r`nTwo`r`nThree`r`nFour"

;choose any
num := "Two"

;check what linefeed is used and assign to lf
lf := (inStr(file, "`r`n")) ? ("`r`n")
	: (inStr(file, "`n")) ? ("`n")
	: (inStr(file, "`r")) ? ("`r") : ("")

;get total lines
totalLines := StrSplit(file, lf).MaxIndex()

;do the loop with the delimeter from above operation
Loop, Parse, file, %lf%
{
	if (A_LoopField == num)
		msgBox % "A_LoopField is:`n" . A_LoopField 
			   . "`n`nParsing worked, found correct line"
	if (A_Index == totalLines){
		msgBox % "Failed"
		break
	}
}
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Loop parse on Unix (LF) file?  Topic is solved

19 May 2019, 05:16

Ok what happen,yesterday no matter what I tried,using Loop Parse was always displaying nothing
Today I tried it again and it magically started to work :?:

Thanks anyway

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Spawnova, william_ahk and 273 guests