SexScripts : How to copy chunks of code - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=129 | Page 1 of 1 |
How to copy chunks of code |
bdartm1 [ Tue Aug 16, 2011 8:10 pm ] |
---|---|
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! |
Re: How to copy chunks of code |
Banjo [ Tue Aug 16, 2011 8:25 pm ] |
---|---|
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. |
Re: How to copy chunks of code |
doti [ Tue Aug 16, 2011 10:16 pm ] |
---|---|
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 ? |
Re: How to copy chunks of code |
bdartm1 [ Wed Aug 17, 2011 12:04 am ] |
---|---|
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. |
Re: How to copy chunks of code |
doti [ Wed Aug 17, 2011 10:08 am ] |
---|---|
No (there are a lot of releases now, but in a few months there will be only one or two a year). |
Re: How to copy chunks of code |
bdartm1 [ Wed Aug 17, 2011 8:11 pm ] |
---|---|
Notepad++ did the trick. Thanks!! |
Re: How to copy chunks of code |
kb215 [ Fri Sep 26, 2014 5:16 am ] |
---|---|
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. |
Re: How to copy chunks of code |
doti [ Sat Sep 27, 2014 10:01 am ] |
---|---|
Writers are not encouraged to use functions in scripts. |
Re: How to copy chunks of code |
kb215 [ Sat Sep 27, 2014 8:17 pm ] |
---|---|
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. |
Re: How to copy chunks of code |
doti [ Sat Sep 27, 2014 8:57 pm ] |
---|---|
Sorry it was not clear. Writers are not encouraged to write some closures in scripts to reproduce the principles of functions. |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |