[Solved]A_index issue in nested file reading loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AllUrBaseRBelong2Us
Posts: 35
Joined: 09 Nov 2015, 11:15

[Solved]A_index issue in nested file reading loop

02 Jan 2016, 09:15

Hey guys,
what I'm trying to achieve here is this:
1.Read a line from file inp.txt
2.Write the line to file tab.txt
3,Read a line from file out.txt
4.Write the line to file tab.txt in the SAME line
5.and so on keeping in mind the current line...

Following code is what I've come up with.
Issue is that it keeps writing the first line of the file out.txt over and over again no matter what the A_Index value is.

Code: Select all

Loop, read, inp.txt
{
	FileAppend, %A_loopreadline%`t, tab.txt
	count:=A_index
	Loop, read, out.txt
	{
		if  (a_index equals count)
		{
			;FileAppend, %A_loopreadline%`n, tab.txt
			break
		}

	}

}
Funnily enough, I've also tried using MsgBox in this place and there's something weird going on.

Code: Select all

Loop, read, inp.txt
{
	FileAppend, %A_loopreadline%`t, tab.txt
	count:=A_index
	Loop, read, out.txt
	{
		if  (a_index equals count)
		{
				
			MsgBox, % a_index "`t" count
			FileAppend, %A_loopreadline%`n, tab.txt
			break
		}

	}

}
The MsgBox statement keeps giving me values like

Code: Select all

11
12
13
14
...
even though the values were checked by the if-condition.
Any help would be appreciated! Thanks in advance.
Last edited by AllUrBaseRBelong2Us on 02 Jan 2016, 12:28, edited 1 time in total.
allthingsarenotequal

Re: A_index issue in nested file reading loop

02 Jan 2016, 12:06

'equals' is not valid ahk code, try the = sign if (a_index = count)
AllUrBaseRBelong2Us
Posts: 35
Joined: 09 Nov 2015, 11:15

Re: A_index issue in nested file reading loop

02 Jan 2016, 12:27

allthingsarenotequal wrote:'equals' is not valid ahk code, try the = sign if (a_index = count)
Thanks; that was a silly oversight on my part.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk and 355 guests