Okay, I fixed the logic with the maxLines error. If I had 501 lines, it would change the maxLines to 501 and then try to read line 501 to see if it was the beginning of a macro... but line 501 is really 502.. hence the error. I don't know why it didn't error sooner or changing the stack would help, oh well.
I also broke apart a pretty stack intensive statement
Code:
[H, if(isCommentLine): tLine = replace(tLine,encode("<!--") + ".*?" + encode("-->"),encode(strformat("[H: '%s']",tTemp)))]
<!-- Changed to -->
[H, if(isCommentLine), code: {
[H: tRegEx = encode("<!--") + ".*?" + encode("-->")]
[H: rText = encode(strformat("[H: '%s']",tTemp))]
[H: tLine = replace(tLine,tRegEx,rText)]
};{}]
edit: Actually, I do know why I didn't see the error before. It only would happen if the code block being transferred was over 500 lines and was the last code block. So, 900 lines would be split in to potentially 500 and 400.. no problem, but 1020 could be 500 and 520 if line 500 was in the middle of the macro. That's when the error would occur. I'm thinking changing the stack had nothing to do with it. The number or lines must have been changed or functions repositioned to avoid the above outcome.
So, I guess here is version 1a which includes my moving of onCampaignLoad to top of output: