Page 1 of 1
How to read the contents of each line in a file loop?
Posted: 26 May 2022, 08:43
by lwx228
I use a loop of external files.Set the file to have multiple lines and only one column.
How do I use variables in an AHK loop to see how many times the loop is going through the file and what the contents of the file are for this loop line?
For example, "D:\test.txt", which has 16 lines.
In a loop where AHK reads files, how can I see the file contents of the first loop as 300002 using a variable
Thanks!
Re: How to read the contents of each line in a file loop?
Posted: 26 May 2022, 11:35
by Rohwedder
Hallo,
try:
Code: Select all
Loop, Read, D:\test.txt
las := A_LoopReadLine, ne := A_Index
or test with MsgBox:
Code: Select all
Loop, Read, D:\test.txt
MsgBox,% (las := A_LoopReadLine) "`n" (ne := A_Index)
Outside the Loop A_LoopReadLine and A_Index no longer exist.
Re: How to read the contents of each line in a file loop?
Posted: 26 May 2022, 17:51
by lwx228
Rohwedder wrote: ↑26 May 2022, 11:35
Hallo,
try:
Code: Select all
Loop, Read, D:\test.txt
las := A_LoopReadLine, ne := A_Index
or test with MsgBox:
Code: Select all
Loop, Read, D:\test.txt
MsgBox,% (las := A_LoopReadLine) "`n" (ne := A_Index)
Outside the Loop A_LoopReadLine and A_Index no longer exist.
Thank you, what I need is how can I see the variable showing the file contents of the first loop :300002
Re: How to read the contents of each line in a file loop?
Posted: 26 May 2022, 23:22
by Rohwedder
With "test with MsgBox" first displayed Msgbox first line?
If it is not that, I need more information e.g. test.txt.
Re: How to read the contents of each line in a file loop?
Posted: 27 May 2022, 00:18
by lwx228
Rohwedder wrote: ↑26 May 2022, 23:22
With "test with MsgBox" first displayed Msgbox first line?
If it is not that, I need more information e.g. test.txt.
Use this command correctly
Thanks!