LoopReadLine, works, can't get it to work as a function Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
HomePlayer
Posts: 9
Joined: 09 Jan 2014, 08:01

LoopReadLine, works, can't get it to work as a function

20 Jun 2018, 02:07

I must be missing something,
The first part will return "21;22;23;25;26"

Code: Select all

kolx := 3
varx := "04-06-2018"
koly := 4
vary := "04-06-2018"
kolz := 5
varz := ""

loop read, % "n.csv"
{
	if a_loopreadline = ""
		continue
	col := strSplit(a_loopreadline, ";", " `t" )
	if (col[kolx] = varx) && (col[koly] = vary) && (col[kolz] != varz)
		items .= A_index ";"
}
msgbox % items
items =

return

f1::
func(kolx,varx,koly,vary,kolz,varz)
	msgbox % items
return

func(kolx,varx,koly,vary,kolz,varz)
{
		global items
		static col
	loop read, % "n.csv"
	{
		if a_loopreadline = ""
			continue
		col := strSplit(a_loopreadline, ";", " `t" )
		if (col[kolx] = varx) && (col[koly] = vary) && (col[kolz] != varz)
			return items .= A_index ";"
	}
}
The function returns only "21;"
What is it that i'm missing

Thanks to grimboto, I totally missed the return part, which is in the loop, thus exit the loop the first time round
Last edited by HomePlayer on 20 Jun 2018, 02:56, edited 1 time in total.
grimboto
Posts: 53
Joined: 09 Jul 2014, 19:20

Re: LoopReadLine, works, can't get it to work as a function  Topic is solved

20 Jun 2018, 02:33

Code: Select all


func(kolx,varx,koly,vary,kolz,varz)
{
		global items
		static col
	loop read, % "n.csv"
	{
		if a_loopreadline = ""
			continue
		col := strSplit(a_loopreadline, ";", " `t" )
		if (col[kolx] = varx) && (col[koly] = vary) && (col[kolz] != varz)
			items .= A_index ";"   ;remove return form this line it exits the function the first time it does this line
	}
	
	return items ; return the items down here when everything has been checked
}

HomePlayer
Posts: 9
Joined: 09 Jan 2014, 08:01

Re: LoopReadLine, works, can't get it to work as a function

20 Jun 2018, 02:54

Omg thanks grimboto
It has to be that simple

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, rc76 and 203 guests