From ftm
Jump to: navigation, search
(ans. from Adrian G)
 
(Category:FAQ)
Line 27: Line 27:
 
definition.
 
definition.
 
</blockquote>
 
</blockquote>
 +
 +
[[Category:FAQ]][[Category:expr]][[Category:ftm.mess]]

Revision as of 13:46, 2 July 2010

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.