Page 1 of 1
User-defineble functions with args?
Posted: 08 Jan 2015 03:15
by stk
Hi,
Couldn't find anything in the doco but wanted to make sure I'm not missing something -
Is it possible to define functions/scripts with arguments/parameters?
eg:
Code: Select all
function sendIt(note, velocity, foo, bar) {
...
}
..would be great for code maintenance.
Cheers,
skye
Re: User-defineble functions with args?
Posted: 08 Jan 2015 08:03
by Softcore
9.6 Defining and Using Functions
In addition to built-in functions and operators, you may define your own mathematical functions
to use in User-defined Variables and expressions. Here’s how to do it:
Select your projects folder in the Project panel, and click the Create Expression button to create a
new Expression.
The Expression is created at the level of the hierarchy you have currently selected. If you have an
Object selected it will be an Expression local to that Object. If you have the Pojects folder selected
the Expression will go there and be available for use anywhere in the Project.
• Type the name of the function and its arguments in parentheses. For example, to define a
function named cubed that takes one argument, you would type:
• Click OK and go to the Script panel to type in the definition of your function as an
expression. You can reference other variables if needed. The example below just multiplies
the function argument a by itself twice to raise the input to the third power.
The newly declared function appears in the Project panel with a Blue dot to indicate it is a function.
How to use the new function? Let’s try it out on a simple Fader: create a Fader Object, make it
horizontal for a change (by stretching it horizontally) name it Cubic and check both its label and
value checkboxes in its properties tab.
Lemur USER GUIDE - page 69
Re: User-defineble functions with args?
Posted: 08 Jan 2015 08:22
by stk
Ah yes, my apologies, I just found that and came back here to edit my original post, to find your reply
Don't know how I missed it in the first place, my only excuse is that it was horribly hot when I was searching and my brain was kind of melting.. Thanks!
Cheers,
skye
Re: User-defineble functions with args?
Posted: 08 Jan 2015 11:23
by Softcore
No probs! Took me a while to find it too, even though I knew it existed!
Re: User-defineble functions with args?
Posted: 08 Jan 2015 16:14
by Phil999
personally I didn't know about it. Thank you.
Oh and if someone knows of a template with self-defined functions, please name it here. I'm interested for what purpose it is used.
Re: User-defineble functions with args?
Posted: 08 Jan 2015 17:42
by midimockup
Holy moly. After years of using Lemur, I totally missed this. Thank you!!!
Re: User-defineble functions with args?
Posted: 08 Jan 2015 18:27
by ndivuyo
Yea my girlfriend showed me this a few months ago and I was: Ohhhhhhhhh! Handy!
Re: User-defineble functions with args?
Posted: 08 Jan 2015 21:47
by Softcore
Hello guys! I 've seen Antonio Blanca using custom functions all the time.
ndivuyo, your girlfriend showed you a Lemur feature? She's a keeper!!!!!
Phil, obviously, such a feature is needed when you require the same function all over your project.....
Here is a very VERY rough example I could think of!