How to read the contents of each line in a file loop?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lwx228
Posts: 49
Joined: 24 Apr 2022, 08:52

How to read the contents of each line in a file loop?

Post by lwx228 » 26 May 2022, 08:43

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!
Attachments
2022-05-26_21-39-23.png
2022-05-26_21-39-23.png (41.95 KiB) Viewed 677 times

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to read the contents of each line in a file loop?

Post by Rohwedder » 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.

lwx228
Posts: 49
Joined: 24 Apr 2022, 08:52

Re: How to read the contents of each line in a file loop?

Post by lwx228 » 26 May 2022, 17:51

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

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to read the contents of each line in a file loop?

Post by Rohwedder » 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.

lwx228
Posts: 49
Joined: 24 Apr 2022, 08:52

Re: How to read the contents of each line in a file loop?

Post by lwx228 » 27 May 2022, 00:18

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!
Attachments
20220527131800.png
20220527131800.png (14.53 KiB) Viewed 565 times

Post Reply

Return to “Ask for Help (v1)”