:?: :?: :?:
Why, oh why do I keep getting "Parser stack overflow" error messages in K2's script editor? :cry: I can sometimes narrow the "culprit" down to "1" perfectly legitimate source line. If I remove this (not necessarily the same line each time), everything is fine.

Are 4340 lines of compiled code too many? I find this hard to believe.

Hi Nickie,
I remember seeing this error message once, but I can't remember the context. Could you please send the line where the error is reported along with a couple of lines before and after. Could it be that you have nested too many block statements (like if, select, while) inside each other? :???:

It is not one particular line. If I compile with compression, it is one line, and if I compile without compression it is another line. And when I have narrowed the problem down to 1 line, I can remove any one of various lines, that correct the problem.

- the on init callback may only have limited number of lines (don't know the number anymore, around 1000 i think)
- if you have too much UI Elements or too much variables this error may occure too. I got this once i had more than 80 UI Elements.

But: i wasn't sure if this problem was there due to the number of variables or the number of lines in the on init callback! (Or both: more variables => more declares in "on init")

What can you do? Try to minimize lines in on init callback, try to declare NO local variables (since they have to be declared all in "on init"). Try to use for example i,j,k for every loop you use, etc...

See what i mean? You declare i in this function. If you have 10 functions you'll ad 10 lines of code to your "on init" callback. If you have 3 local loop counter variables in each function you add 30 lines to on init. I know code gets better readable if you do those local declares. It's a pitty those limitations of KSP make a lot of Nil's work almost useless in big projects :(

This was one of the most anoying error messages i got. Because i had to rewrite a lot. But after all: now i try to keep the size of the "on init" callback as small as possible.

Somewhere there should be a thread were i already posted this (i think it was in the "welcome back big bob" thread.

BTW: Could you please send the number of lines in your "on init" callback and the number of variables you use? Because if you do, i can say for sure if this is your problem.

What i really hate about NI and KSP: they had set some limits and nobody knows these limits! How many variables may be declared? How many ui elements? How many callbacks? How many lines per callback? It's really anonying!

I have the nasty feeling, you are right. If you are, it is really bad news. There are 1485 "on init" lines in the uncompressed compiled code and 1130 in the compressed, and 384 variables. I'll try and reduce the size of "on init". Thank you for your help, both of you. :smile:

I think I found the problem :smile:. It seems that the number of top-level statements (or statements at the same level) is restricted to about 995. However, you can work around this by introducing some artificial nesting. Eg. change this:

Code:

line1
line2
...
line1500

into:

Code:

if (1=1)
line1
line2
...
line750
end if
if (1=1)
line751
line752
...
line 1500
end if

I think I found the problem :smile:. It seems that the number of top-level statements (or statements at the same level) is restricted to about 995. However, you can work around this by introducing some artificial nesting. Eg. change this:

Code:

line1
line2
...
line1500

into:

Code:

if (1=1)
line1
line2
...
line750
end if
if (1=1)
line751
line752
...
line 1500
end if

Cheers,
Nils

Click to expand...

I'll try your solution. Thanks!

Right now I am struggling with a (declared!) variable, which Kontakt claims is not declared. Yeah, right! :evil:

You might want to watch out for empty if-statements (commented out code counts as empty) and assigning to builtin variables. I think there are some bugs related to these. Good luck!

Click to expand...

Thanks.

In this case it is the variable carrying the value of a "set_controller" statement. The statement has been parsed successfully before, so obviously the problem is somewhere else, possibly far away from the error line. :roll:

Version 2 of the G Strings script for the Garritan Solo Strings. I am improving the GUI and adding some new features. It keeps growing and growing and... Apparently I can't stop getting ideas for new features :lol:

Well, I finally got rid of the "parser stack overflow" messages. Oddly enough with the same variables and almost the same number of compressed "on init" lines (1112 against the 1130, that caused trouble). I just basically shuffled everything around.

Well, I finally got rid of the "parser stack overflow" messages. Oddly enough with the same variables and almost the same number of compressed "on init" lines (1112 against the 1130, that caused trouble). I just basically shuffled everything around.

Right now I am struggling with a (declared!) variable, which Kontakt claims is not declared. Yeah, right! :evil:

Click to expand...

Another cause of this problem might be initializing variables to non-constant values. It seems that Kontakt doesn't always report this problem, and in some cases it causes declared variables to be considered undeclared. Please split declarations and assignments to two different rows, eg:declare $x := find_group("test")change into:declare $x
$x := find_group("test")

Another cause of this problem might be initializing variables to non-constant values. It seems that Kontakt doesn't always report this problem, and in some cases it causes declared variables to be considered undeclared. Please split declarations and assignments to two different rows, eg:declare $x := find_group("test")change into:declare $x
$x := find_group("test")

Click to expand...

Yes, I did figure this out eventually - after I had spent a lot of time moving assignments to declaration lines in order to reduce the number of lines :wink: :roll: But thanks anyway :smile: