If working on big Kontakt projects with heavy macros or code segments inside the on init you may get confronted with the “parser stack overflow” error. This simple workaround shows how to avoid this error.
According to this post @ vi control you can only have a specific amount of code lines in the same statement level hierarchy – inside the on init. The limit is about 996 lines in each level.
So if we get the parser stack overflow error we can simply wrap some of our code parts inside an if clause which is always true. By this we put our code one hierarchy down. Like so:
on init // lots of code in the top level hierarchy if (1=1) //even more code in the second level hierarchy (+ 996 lines) end if if (1=1) // another code block in the second level hierarchy (+996 lines) end if end on
The limit of 996 lines is not really verified. So just do this procedure for as many code blocks until the stack overflow error disappears.
Note: The total allowed lines of code inside the on init is still limited. But you should be good if you don’t exceed about 11.000 lines.
For macros it just would look like this:
macro xyz if(1=1) // your macro code end if end macro
Related Posts / Source: