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.