From ftm
Jump to: navigation, search
Line 30: Line 30:
  
 
I  check the output tuples as list checkbox in the ftm.mess inspector
 
I  check the output tuples as list checkbox in the ftm.mess inspector
 +
 
II (l (if ((llen $*1) == 3) {$*1}))
 
II (l (if ((llen $*1) == 3) {$*1}))

Revision as of 11:47, 5 August 2010

Working with inputs in the ftm.mess object is analogous to the standard Max message object: $1 refers to inlet 1 etc. Lists are also 'spread out', so

($1 + $2)

with '1 3' in the left inlet will give you the sum of 1 and 3. Let's say we would like to only let lists of a certain length go through, you need to somehow get the list as a whole. This can be done with $*i, which gets the input list at that specific inlet rather than the corresponding element from that list.

($*1) will output the input list.

Next, we check for the length and decide whether or not to output:

(if ((llen $*1) == 3) $*1) --> this will NOT work!

In this case, the order in which things get evaluated inside the ftm.mess object, is crucial. The two $*1 statements are independent, in that there is, in this case, no operation that actually modifies the input variables ($1, $2...). So you can safely ask for the length of the input for use in the if statement and use the input again to output if the statement is true. The problem in this case is that the list gets evaluated first and the first two elements are then used as the options for the if statement. So for example

(if 1 $*1) with 4 5 6 as the input will give you 4, whereas (if 0 $*1) with the same input will give you 5

the 6 gets lost in this construction.

So, what if we need to get the list through? We have to make it an object and pass it as a whole. This can be any ftm.object, let's say a tuple:

(if ((llen $*1) == 3) {$*1}) --> this will work, but you end up with a tuple. So finally there are two ways to handle this inside the same object:

I check the output tuples as list checkbox in the ftm.mess inspector

II (l (if ((llen $*1) == 3) {$*1}))