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


Post new topic Reply to topic  [ 10 posts ] 
Author Message
 How to copy chunks of code
PostPosted: Tue Aug 16, 2011 8:10 pm 
Offline
Regular
How do you copy a section of code that you might want to use again at a later part of the program or in an additional script without having to rewrite the whole section. Within groovy I don't seem to be able to copy a selected section to paste somewhere else and if I save it as a text file the formatting is a complete mess.

Thanks!


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Tue Aug 16, 2011 8:25 pm 
Offline
Veteran
User avatar
Using the built-in editor, you can use "shift-highlight" and then "ctrl-c" (copy) and "ctrl-p" (paste) like in a word processor, can't you?

As for saving as a text file, I use 'EditPad Pro' but a similar program like Notepad++ or Programmer's File Editor should keep the right formatting when you use them to edit/save a groovy script, I think.


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Tue Aug 16, 2011 10:16 pm 
Offline
Site Admin
User avatar
I added cut/copy/paste in the editor (release 08/16/2011 - 0.96.6), to know where is the problem. You should be able to do copy/paste in and out the editor. What is your system ?


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Wed Aug 17, 2011 12:04 am 
Offline
Regular
Thanks both of you. Any special way to update the program other than download a whole new download? System Windows 7 if that is what you are asking.


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Wed Aug 17, 2011 10:08 am 
Offline
Site Admin
User avatar
No (there are a lot of releases now, but in a few months there will be only one or two a year).


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Wed Aug 17, 2011 8:11 pm 
Offline
Regular
Notepad++ did the trick. Thanks!!


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Fri Sep 26, 2014 5:16 am 
Offline
Active member
bdartm1 wrote:
How do you copy a section of code that you might want to use again at a later part of the program or in an additional script without having to rewrite the whole section ...

Thanks!



Using functions (sometimes called methods) is so very important to writing a good script. Instead of writing the same code over and over write it once at the top of the file ...

Code:
def loopBeat(BPM, timeon, timeoff) {
  int s = 0;
  your loop code here

   s++;
   return s;
}


Then call it

Code:
def CompletedStrokes = loopBeat(120, 30, 10);

// change speed
CompletedStrokes = loopBeat(180, 40, 20);


With the return statement you can get results from the function, like how many times the user looped or stroked ... a metronome function rather than copy pasting the same loop.


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Sat Sep 27, 2014 10:01 am 
Offline
Site Admin
User avatar
Writers are not encouraged to use functions in scripts.


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Sat Sep 27, 2014 8:17 pm 
Offline
Active member
How come?

Functions are pretty fundamental to computer programming, that's not an opinion I have I'm not saying we should use functions because I believe in functions ... software is made of functions. For repeat tasks and big indepth scripts wouldn't it save a lot of lines and make writing a script eaiser for the writer?

Plus it would give you useful code that you could implement in future API's making the software even better?

show() is a function wait() is a function loadString() is a function, are we discouraged from using these? I don't understand why there would be a discouragement from making good code.


Top
 Profile Send private message 
 
 Re: How to copy chunks of code
PostPosted: Sat Sep 27, 2014 8:57 pm 
Offline
Site Admin
User avatar
Sorry it was not clear.

Writers are not encouraged to write some closures in scripts to reproduce the principles of functions.


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 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.