de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Long Scripts?
PostPosted: Tue Mar 19, 2013 6:47 am 
Offline
Regular
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,


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Tue Mar 19, 2013 9:17 am 
Offline
Site Admin
User avatar
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).


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Tue Mar 19, 2013 5:59 pm 
Offline
Regular
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.


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Tue Mar 19, 2013 9:12 pm 
Offline
Site Admin
User avatar
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.


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Wed Mar 20, 2013 4:55 am 
Offline
Regular
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.


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Wed Mar 20, 2013 9:57 am 
Offline
Site Admin
User avatar
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 ?


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Wed Mar 20, 2013 1:24 pm 
Offline
Regular
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?


Top
 Profile Send private message 
 
 Re: Long Scripts?
PostPosted: Wed Mar 20, 2013 2:53 pm 
Offline
Site Admin
User avatar
Big content is a part of your code.
You can separate it in any number of pieces that you need (not only 2).


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.