KONTAKT - Script with while-loops nested that stop on the way

VST, AU, AAX, etc. plug-in Virtual Instruments discussion
hellishvictor
KVRist
131 posts since 29 Apr, 2008

Post Thu May 16, 2019 7:16 am

Hi world,

Here is a nested while-loops executed on the init callback that I can't make it finish, since it stop somewhere when the instruments have many groups, and everything that is after it.
Tons of things have been left out to make it very simple here, leaving only the "add_text_line", but as it flow, it should go storing values on big arrays.

Code: Select all

	$groups := 0
	while ($groups < $NUM_GROUPS)
		add_text_line($whatever, group_name($groups) & " " & $groups)
		$acount := 0
		while ($acount < 40)
				add_text_line($whatever,"acount: " & $acount)
				$xcount := 0
				while ($xcount < 9)
					add_text_line($whatever,"xcount: " & $xcount)
					inc($xcount)
				end while
			inc($acount)
		end while
		inc($groups)
	end while
Cheers

User avatar
EvilDragon
KVRAF
17988 posts since 7 Jan, 2009 from Croatia

Re: KONTAKT - Script with while-loops nested that stop on the way

Post Thu May 16, 2019 8:34 am

Loops in KSP have a maximum of around 30-40k iterations. If you have a huge number of groups, this is why your above code won't work.

If you need to initialize a huge array, I suggest using a NKA file loaded from resource container (load_array() mode 2 - but if you're on K4 still, this won't work).

hellishvictor
KVRist
131 posts since 29 Apr, 2008

Re: KONTAKT - Script with while-loops nested that stop on the way

Post Tue May 21, 2019 11:01 am

Thanks for the info EvilDragon, but finally I found out days ago that it will work only if there's a short wait on the while-loop; and since it cannot be done from the init callback, the while-loop must put on a function invoked with a trigger pgs callback. Works like a charm now, I can't believe it!

Return to “Instruments”