SexScripts : Long Scripts? - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=304 Page 1 of 1

Long Scripts?

sissy666 [ Tue Mar 19, 2013 6:47 am ]

My script just exceeded 110K and it bombs when I try and load it.
What's the best way around this?
Is there an 'include' command to combine source code from different files with each individual code < 100K?
I really need access to the same variables in all the subroutines, so I don't think I can just call another script and then use return.
There is an 'evaluate' command in the groovy documentation, but I can't get it to work.
I hope the community can give me an answer.
Thanks,

Re: Long Scripts?

doti [ Tue Mar 19, 2013 9:17 am ]

Wow 110k. I didn't know it failed in this case, it should not. I'd like to try and correct this -> when does it crash ? When loading on the main Window ?

You can not include another script, see here for communication between scripts (solution : saving/loading).

Re: Long Scripts?

sissy666 [ Tue Mar 19, 2013 5:59 pm ]

Yeah, 110K I get carried away.
Failure is a popup on loading the script that says
Message
Error org.codehaus.groovy.control . . .
Method code too large!

Breaking in chunks is hard, but I may have to. Hope for an answer.

Re: Long Scripts?

doti [ Tue Mar 19, 2013 9:12 pm ]

Ok I could replicate the error. :)
And I do not see any solution (apart splitting the script in multiple ones). :(

If you're not sure, I can do the splitting for you, let me know.

Re: Long Scripts?

sissy666 [ Wed Mar 20, 2013 4:55 am ]

Glad I'm not crazy (though stupid errors are fixable).

Could you give me a pointer to documentation on splitting into multiple groovy scripts?

Can I pass and return arguments (at least)? The Forum seems to indicate you can't re-enter a script, but have to return to the beginning after a 'call' to another script.

Saving/loading seems limited to strings, booleans and numbers. I can save a list, but I can't get it back into a script. It comes back in as a string and I can't get typecasting to work to put the string back into a list. I've tried a bunch, but no joy.

Re: Long Scripts?

doti [ Wed Mar 20, 2013 9:57 am ]

I tried, with success, to use minimalist closure (inside methods) to split inside one file
Code:
def doPart1 = {
//big content
}
doPart1()
def doPart2 = {
//big content
}
doPart2()

Variables are shared amongs multiples parts.

:!: Warning : due to a design error, in parts you must not write wait(3) but super.wait(3) (<= edit : not true anymore, do as you want)

Saving/loading lists : this solution did not work ?

Re: Long Scripts?

sissy666 [ Wed Mar 20, 2013 1:24 pm ]

Doti:

Double Thanks!

I will try the list save method.

I think you've solved the size problem, though I don't fully grasp closures or methods.
I replaced //big content in doPart1 with ~5000 lines of show("bla bla bla"); until one more line choked it.
Then I could put nearly the same number of lines in doPart2. All run. Variables outside of the two closures are
visible inside both closures and the outside scope.

Thanks for the warning on wait(). I'd already written my own using the internal groovy function.

Back to scripting.

def doPart1 = {
//big content
}
doPart1()
def doPart2 = {
//big content
}
doPart2()


Where does the code for 'big content' go? Is //big content replaced by code or the name of a script?

Re: Long Scripts?

doti [ Wed Mar 20, 2013 2:53 pm ]

Big content is a part of your code.
You can separate it in any number of pieces that you need (not only 2).

Page 1 of 1 All times are UTC + 1 hour [ DST ]
https://ss.deviatenow.com:443/
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2011