官术网_书友最值得收藏!

Displaying messages

The Hello World example is straightforward. It involves one piece of data—a Hello World message, and one object to print out the message in the console window.

Create a new Pure Data patch. Save it to your folder with name helloWorld.pd. Clear the console window by navigating to Edit | Clear console. To create anything for your Pure Data patch, choose from the Put menu item.

It may take a few seconds for new comers to learn the operations of the Pure Data interaction sequence. First, we select a Message box (Command + 2 or Ctrl + 2). After you select Message, move your cursor back to the empty patch window helloWorld.pd. The message icon will move along with your cursor. You can click anywhere on the empty patch to fix the position of the message icon.

A data entry cursor (a blinking vertical bar) will appear in the left hand side of the message box. Now, you can type in Hello World inside this message box.

Click anywhere outside the message box to confirm the text. Note that the data entry cursor will disappear after you confirm the text. You can click on the message box again if you want to change the text later. You can also click-and-drag the message box to change its position within the patch window.

Now, we create the second item. Navigate to Put | Object (Command + 1 or Ctrl + 1) from the menu bar to create an empty object in the patch window.

Type the word print inside the object box. Note that the empty object box is a regular rectangle with dotted outline. After you type print, click outside the object box. The object box now has a solid outline. A message box is a rectangle with a curved right edge.

If you take a closer look at the message and object boxes, you will notice two tiny rectangles along the left edge of the message box on the top and bottom. For the object box, there is only one such rectangle on the top. They are the inlet and outlet mentioned earlier. Those on the top are inlets and those on the bottom are outlets.

Connecting one outlet to another inlet is the programming in Pure Data. Now, we connect the outlet of the Hello World message box to the inlet of the print object box. First, move your cursor towards the outlet of the Hello World message box. It will turn into a small circle.

Click-and-drag to draw a line from the outlet of the Hello World message box. While dragging, move toward the inlet of the print object box. The cursor will also turn into a small circle.

Release the mouse button to confirm the connection.

This is your first working Pure Data patch, the Hello World program. To execute the patch, we have to switch from Edit Mode to Run Mode by choosing Edit | Edit mode (Command + E or Ctrl + E). Note the mouse cursor changes into the regular pointer shape. Open the console window if it is hidden. You can do it by navigating to Window | Pd window (Command + R or Ctrl + R). Arrange the two windows side by side such that you can see the message in the console window when you work on the patch window. Move your cursor toward the Hello World message box. Note the cursor changes again. It is now an upward pointing arrow.

Click on the message box and note what happens in the console window. A message print: Hello World appears whenever you click on the message box. Yes, it is the Hello World program you have just achieved.

The message box in Run Mode functions like a button. When you click, it sends out the message text Hello World through its outlet along the connection line to the inlet of the print object box. A print object will just show the message it received onto the console window.

Note

In Edit Mode, you can also hold down the Command key or the Ctrl key to enter the Run Mode temporarily.

主站蜘蛛池模板: 桐庐县| 宁都县| 泽库县| 柳河县| 临沂市| 乌审旗| 裕民县| 玛纳斯县| 西乡县| 宜宾县| 新田县| 濮阳市| 南京市| 专栏| 甘孜县| 台州市| 图木舒克市| 甘德县| 神农架林区| 怀宁县| 文山县| 彭水| 滁州市| 肇东市| 南安市| 洪江市| 保康县| 永善县| 永平县| 游戏| 南丰县| 济阳县| 龙游县| 清新县| 会泽县| 唐山市| 敖汉旗| 科技| 福海县| 西吉县| 绵竹市|