substitute Reference

Substitute symbols within a message

substitute

Description

Matches messages to its own arguments; whenever it finds a match, will make the appropriate substitution.

Examples

substitute can translate messages output by one object to what's expected by another object

Arguments

match [anything]

Optional

The first number or symbol specifies the match, which identifies what should be replaced in an incoming message. The default match value is 0.

replacement [anything]

Optional

The second number or symbol specifies the replacement for the match. The default replacement value is 0.

mode [anything]

Optional

Any third number or symbol sets the "replace first message only" mode of the substitute object. Only the first instance of the specified match will be replaced.

Attributes

Common Box Attributes

Messages

bang

Same as anything.

int

Arguments

input [int]
Same as anything.

float

Arguments

input [float]
Same as anything.

list

Arguments

input [list]
Same as anything.

anything

Arguments

input [list]
In left inlet: The input is echoed to the output, but if the message received contains an element matching the match symbol or number, the element is replaced by the replacement symbol or number when the message is repeated to the output.

In right inlet: The substitute object accepts a message of two numbers or symbols in its right inlet. The first number or symbol specifies the match, which identifies what should be replaced in an incoming message.

set

Arguments

input [list]
In left inlet: Same as anything.
In right inlet: Same as anything, except that the word set is ignored.

Output

anything

Out left outlet: The input message is echoed to the output with elements matching the match symbol or number replaced by the replacement number or symbol.

bang

Out right outlet: If no substitution occurred when sending out the incoming message, the original input message is passed out the rightmost outlet.

See Also

Name Description
route
sprintf
zl