General
User-defineble functions with args?
Started by stk on .
Sign in or create an account to join the conversation.
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:
Cheers,
skye
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:
function sendIt(note, velocity, foo, bar) {
...
}
..would be great for code maintenance.Cheers,
skye
[size=150]9.6 Defining and Using Functions[/size]
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
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
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
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
No probs! Took me a while to find it too, even though I knew it existed! 
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.
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.
Holy moly. After years of using Lemur, I totally missed this. Thank you!!!
Yea my girlfriend showed me this a few months ago and I was: Ohhhhhhhhh! Handy!
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!
customFunctionExample.jzml
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!
customFunctionExample.jzml