Expression Class Arguments

From ftm

Q: How to pass an argument to a method involving an expression object?

A: Here is how to pass the variable to expr:

($1 apply (new expr '($x * $1)') $localvar)

or

[ $fvecref $localvar ]
|
[ ($1 apply (new expr '($x * $1)') $2) ]

You stick the arguments which you want to pass to expr after the expression itself in the message box.

Reference from fvec help patch:

When it is evaluated by the apply method, the expression object can only access arguments to apply as $1, $2..., the method-specific variables $x and $self, and global variables. Local variables used in the expression definition are undefined since a method can not access the context (patcher) in which it is invoked. Therefore, you have to pass references to local variables as arguments to apply, which will replace $1, $2, etc. in the expression definition.

See also Expr_demystified