Download Tutorials and Topics

Transcript
Tutorial 2: The bang Message
The bang Message
•
This program is actually three separate printing programs. Click on the button icons in each
program and notice what gets printed in the Max window.
The first thing to observe is that two of the print objects have names: x and y. Since there can be any
number of print objects in a Patcher window, you will often want to make it clear which one is
actually printing a message. You do this by putting a name after the word print in the box. When
there’s no name, the message is preceded by print:, as in Program 1. When there is a name, it precedes the message, as in Programs 2 and 3.
The second important new thing in this window is the button object. It appears as a separate item
in the palette, and is really very much like a message box that contains the message bang.
You see, bang is a magic word in Max. It’s a special message that means, “Do it!”, which causes an
object to do whatever it’s supposed to do. For example, a message box sends out the message it
contains in response to a bang or a mouse click.
•
In Program 1, you can click on the “Gotcha!” message box to print it, or you can click on the
button, which sends a bang message to the inlet of the message box. The effect is equivalent,
since in either case the message box is “triggered” and sends out the message it contains.
•
Program 2 not only proves that the button quite literally sends the message bang; it also proves
that bang has no special effect on the print object. That’s because the print object doesn’t try to
understand the message it receives. Its only purpose in life is to print out what arrives in its
inlet.
•
Program 3 is sort of a puzzler. Clicking on either button produces a printout of y: bang.
13