Notifications
Clear all

[Closed] problem with function on startup

Hi,

I have this function in my startup file in stdscripts folder to run as one of the first functions. I need to use it frequently for my pipeline. Here is a function:

fn getDirs root pattern = (
	patt = "*" + pattern + "*"
	dirArr = #()
	dir_array = GetDirectories (root + "/*")
	for d in dir_array do (
		join dir_array (GetDirectories (d + "/*"))
	)
	for i=1 to dir_array.count do (
		if (matchPattern dir_array[i] pattern:patt == true) do (
			append dirArr dir_array[i]
		)
	)
	dirArr
)
getDirs()

Now the problem is that it does not load properly on startup. At the end of the code i have getDirs() to see what is the response, and it is proper:

-- Argument count error: getDirs wanted 2, got 0 <<

Now if I run this function with some two items (eg. getDirs proj_root_path “publish”) I always get this error:

-- Argument count error: getDirs wanted 1, got 2

Which does not make sense since this function use 2 items ont 1?!

So what I need to do is to manually run the code for the function and than it works…

Why is this happening? Why on startup it wants 2 but then it wants only 1 item to run?