General

User-defineble functions with args?

Started by stk on .

Sign in or create an account to join the conversation.

8 posts

Topic starter
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:
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
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