aboutsummaryrefslogtreecommitdiff
path: root/doc/pddp/all_about_atom_conversion.pd
blob: 9e0cb1bd1ebb0eed5fc84b1b4832ecfdafd9bda0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#N canvas 0 0 448 248 10;
#X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header atom_conversion
20 10 1 18 -261106 -33289 0;
#X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp
;
#X obj 43 80 pddp/pddplink all_about_messages.pd;
#X obj 1 226 cnv 15 445 20 empty \$0-pddp.cnv.footer empty 20 12 0
14 -233017 -33289 0;
#N canvas 44 246 494 344 META 0;
#X text 12 65 HELP_PATCH_AUTHORS Dave Sabine \, May 5 \, 2003 . Jonathan
Wilkes revised the patch to conform to the PDDP template for Pd version
0.42.;
#X text 12 5 GENRE all_about_pd;
#X text 12 25 KEYWORDS needs_work;
#X text 12 45 DESCRIPTION how to convert Pd atoms;
#X restore 392 228 pd META;
#N canvas 14 133 428 105 Related_objects 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261106 -33289 0;
#X text 7 2 Atoms- Related Objects;
#X floatatom 22 43 5 0 0 0 - - -;
#X symbolatom 22 67 10 0 0 0 - - -;
#X obj 105 42 makefilename;
#X obj 200 60 pddp/helplink cyclone/fromsymbol;
#X obj 200 80 pddp/helplink zexy/symbol2list;
#X obj 311 59 pddp/helplink zexy/list2symbol;
#X obj 311 79 pddp/helplink cyclone/tosymbol;
#X obj 200 40 pddp/pddplink all_about_externals.pd -text _________
;
#X obj 200 40 pddp/pddplink all_about_externals.pd -text Externals
;
#X restore 103 228 pd Related_objects;
#X obj 6 228 pddp/pddplink all_about.pd -text All About Pd;
#X text 208 106 <- give some links to the manual;
#X obj 43 65 pddp/pddplink all_about_atoms.pd;
#X text 42 36 Converting between atom types in Pd can be tricky. Make
sure you have read the following help patches first:;
#N canvas 9 155 428 140 symbol-atom_to_float 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 20 10
1 18 -261106 -33289 0;
#X text 7 1 From a symbol-atom to a float;
#X obj 20 70 pddp/helplink cyclone/fromsymbol;
#X obj 20 90 pddp/helplink zexy/symbol2list;
#X text 20 37 There are no internal objects to turn a symbol-atom into
a float. There are two important externals for this \, however:;
#X restore 43 149 pd symbol-atom_to_float;
#N canvas 14 48 428 554 float_to_symbol-atom 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 20 10
1 18 -261106 -33289 0;
#X text 7 1 Changing a float to a symbol-atom;
#X obj 45 163 hsl 128 15 0 127 0 0 empty 123 empty -2 -8 0 10 -262144
-1 -1 7000 1;
#X text 19 79 For example \, you can enter a number for the "receive-symbol"
of the so-called IEMGUIS like the slider below. Since receive-names
need to be symbol-atoms \, the GUI automatically converts "123" to
a symbol-atom after you click "Ok" or "Apply" in the "Properties" dialogue.
;
#X text 181 158 <- hslider with receive-symbol "123";
#X msg 42 353 symbol 123;
#X obj 42 375 print empty_symbol;
#X msg 151 457 123;
#X text 192 456 <- try it;
#X obj 151 479 makefilename %d;
#X text 255 479 <- outputs "symbol 123" \,;
#X text 255 494 where "123" is a real;
#X text 255 509 symbol-atom;
#X obj 130 503 send;
#X floatatom 93 479 5 0 0 0 - - -;
#X text 19 395 The [makefilename] object will do the trick \, however.
It always outputs a symbol message (remember that a symbol message
must have a symbol-atom as an element) \, and so it can convert an
incoming float to a symbol-atom:;
#X text 19 494 Also see:;
#X obj 20 514 pddp/helplink zexy/list2symbol;
#X obj 20 529 pddp/helplink cyclone/tosymbol;
#X text 19 36 Problem: some objects in Pd expect certain atom types
and will complain with an error if they receive the wrong type. Other
objects will silently make the conversion for you.;
#X text 19 183 Note that there's no visible difference between the
float "123" and the symbol-atom "123"-- the only difference is in how
these character are understood by Pd. If I want to send a value to
the slider using [send] \, there is a problem because [send] doesn't
do any atom conversion-- if you try to create [send 123] you'll get
an error.;
#X text 19 267 However \, you can send a symbol message to the right
inlet of [send] to specify the send-name. You might think that using
a symbol message will convert the number to a symbol-atom. Unfortunately
\, that doesn't work either-- the message box silently ignores the
float and outputs an empty symbol:;
#X connect 5 0 6 0;
#X connect 7 0 9 0;
#X connect 9 0 13 1;
#X connect 14 0 13 0;
#X restore 43 106 pd float_to_symbol-atom;
#N canvas 22 133 428 426 multiple_atoms_to_one_symbol-atom 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 20 10
1 18 -261106 -33289 0;
#X text 7 1 Concatenate multiple atoms;
#X msg 42 98 list one 2 3;
#X msg 140 98 1 2 3;
#X msg 42 131 symbol \$1\$2\$3;
#X symbolatom 42 158 10 0 0 0 - - -;
#X text 19 36 Dollarsign variables can be used to join several atoms
together to form one atom. The result is always a symbol-atom.;
#X text 139 131 \$1\$2\$3 is always a symbol-atom \,;
#X text 139 148 so we can safely use it build a;
#X text 139 165 symbol message.;
#X obj 42 277 makefilename Program%cFiles;
#X symbolatom 42 301 0 0 0 0 - - -;
#X msg 42 250 32;
#X obj 41 352 pddp/helplink zexy/list2symbol;
#X obj 41 372 pddp/helplink cyclone/tosymbol;
#X text 19 196 There are also times when you may need to create a symbol-atom
that contains spaces in it. Use the %c argument with [makefilename].
;
#X text 19 335 For more complex constructions \, see:;
#X connect 2 0 4 0;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 10 0 11 0;
#X connect 12 0 10 0;
#X restore 43 128 pd multiple_atoms_to_one_symbol-atom;
#X text 42 171 See also:;
#X obj 43 187 pddp/pddplink all_about_message_conversion.pd;
#X obj 43 202 pddp/pddplink all_about_symbol_construction.pd;