#N canvas 262 61 1034 611 12;
#X obj 166 328 print x1;
#X obj 244 328 print x2;
#X obj 322 328 print x3;
#X obj 166 247 route 23 54 1, f 34;
#X msg 149 153 234 345 456;
#X msg 166 179 23 34 45;
#X msg 181 205 54 43;
#X msg 230 206 1 foo bar;
#X msg 261 411 impeach ringo starr;
#X obj 171 440 route big apple, f 27;
#X msg 171 380 apple pie;
#X msg 118 380 1 2 3;
#X msg 254 380 big apple pie;
#X msg 50 153 walk the dog;
#X text 30 247 numeric arguments:;
#X text 25 440 symbolic arguments:;
#X obj 171 520 print y1;
#X obj 264 520 print y2;
#X obj 26 13 route;
#X text 788 573 updated for Pd version 0.43;
#X msg 596 185 1 2 3;
#X floatatom 663 218 5 0 0 0 - - - 0;
#X msg 605 212 4 5 6;
#X obj 401 328 print rejected;
#X obj 357 520 print rejected;
#X obj 791 233 route hi, f 10;
#X msg 759 177 hi there;
#X msg 791 205 see ya;
#X symbolatom 858 205 6 0 0 0 - - - 0;
#X msg 866 178 symbol see;
#X obj 791 310 print s1;
#X obj 858 310 print s2;
#X text 80 14 - trim first element and route messages according to it;
#N canvas 432 122 920 716 special-selectors/message-types 0;
#X msg 454 221 5;
#X msg 519 238 symbol pie;
#X msg 424 195 1 2 3;
#X msg 58 511 list a b c;
#X obj 58 580 route list symbol;
#X floatatom 83 151 5 0 0 0 - - - 0;
#X obj 191 266 print route-list;
#X floatatom 137 253 5 0 0 0 - - - 0;
#X obj 137 295 print route-float;
#X obj 137 215 route float list;
#X msg 80 543 symbol zorglub;
#X obj 116 623 print untrimmed;
#X obj 58 659 print trimmed;
#X obj 488 332 list;
#X msg 389 169 list x y z;
#X msg 602 594 pie;
#X obj 488 306 route list float symbol bang pure, f 56;
#X msg 532 266 pure data;
#X text 607 266 not a special selector;
#X obj 280 640 route a b;
#X obj 280 602 list trim;
#X msg 291 548 list b 52;
#X msg 280 516 list a 3;
#X floatatom 280 675 3 0 0 0 - - - 0;
#X floatatom 310 675 3 0 0 0 - - - 0;
#X obj 602 643 route pie;
#X msg 679 573 symbol pie;
#X obj 679 600 list trim;
#X text 517 547 Note that [list trim] also trims the symbol selector., f 32;
#X obj 729 473 route 12;
#X msg 729 441 12;
#X listbox 191 241 20 0 0 0 - - - 0;
#X listbox 137 180 20 0 0 0 - - - 0;
#X msg 137 149 1 2 3 4 5 6 7;
#X listbox 488 358 8 0 0 0 - - - 0;
#X floatatom 565 349 5 0 0 0 - - - 0;
#X symbolatom 643 349 8 0 0 0 - - - 0;
#X obj 721 349 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X symbolatom 814 360 8 0 0 0 - - - 0;
#X obj 814 334 symbol;
#X text 740 152 [route] also deals with pointers \, see:, f 12;
#X text 497 445 [route] outputs bangs when matching messages that have no further elements. This case is quite similar to [select], f 30;
#X obj 355 169 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 729 502 print [route 12];
#X obj 602 676 print [route pie];
#X text 26 16 Numbers in Pd are always given a 'float' selector. Similarly \, lists that start with floats are given the 'list' selector. These are implicit selectors and they stick to the message even if you can't see it. This means that if you use [route] with 'float' and 'list' in these cases \, you can route according to the message type \, but the selectors are kept implicitly., f 50;
#X text 27 336 On the other hand \, a "list a b c" message gets its list selector trimmed when passed through [route list] - as in the usual behaviour of the object. The exception and inconsistency is with 'symbol' messages \, where the symbol selector is kept when it shouldn't. This is a known bug that's been here forever and just won't be fixed anymore., f 56;
#X text 27 444 Note that if you want to route according to the first element of a list message \, you need to first trim its selector with [list trim]., f 56;
#X msg 502 200 list apple;
#X msg 495 176 list 1;
#X msg 488 152 list;
#X obj 488 387 print list, f 5;
#X obj 565 387 print float, f 5;
#X obj 643 387 print symbol, f 6;
#X obj 721 387 print bang, f 5;
#X obj 799 387 print non-special, f 12;
#X text 551 160 special handling of 0/1-element lists, f 19;
#N canvas 728 98 559 323 pointer 0;
#X obj 90 111 bng 17 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#N canvas 491 316 412 249 open 0;
#X obj 58 49 inlet;
#X obj 58 105 pdcontrol;
#X msg 58 78 dir;
#X msg 58 132 \; pd open 01.scalars.pd \$1/../4.data.structures;
#X connect 0 0 2 0;
#X connect 1 0 3 0;
#X connect 2 0 1 0;
#X restore 90 141 pd open;
#X text 35 17 The [route] object can also route a pointer or a list of pointers. A pointer can be the location of a Data Structure scalar somewhere or the head of a Data Structure list. To know more about Data Structures \, how to handle pointers and see examples \, please refer to the 4.Data.Structure section of the Pd's tutorials., f 70;
#X text 44 189 You should use the "pointer" argument to route pointers \, and in this case [route] does indeed expect a pointer data type and nothing else. The 'pointer' selector is not removed in this case., f 65;
#X text 44 244 In the case of a list of pointers \, the "list" argument should be given \, and this is another case where the 'list' selector is not trimmed!, f 65;
#X text 114 110 <-- open first example of the 4.data.structures section;
#X connect 0 0 1 0;
#X restore 775 202 pd pointer;
#X text 600 238 symbol selector;
#X text 421 16 The bang message can also be used as a symbol argument for [route] and it matches to a bang input. Below we route messages according to its type. Note that we have a [list] object to give the 'list' selector back in the case of list messages that start with a symbol. Also beware of special handling of 0/1-element lists ('list' becomes a bang \, and one element lists become float or symbol). Note also that you can still use other symbols to route other messages (as with 'pure' below)., f 66;
#X connect 0 0 16 0;
#X connect 1 0 16 0;
#X connect 2 0 16 0;
#X connect 3 0 4 0;
#X connect 4 0 12 0;
#X connect 4 1 11 0;
#X connect 5 0 9 0;
#X connect 7 0 8 0;
#X connect 9 0 7 0;
#X connect 9 1 31 0;
#X connect 10 0 4 0;
#X connect 13 0 34 0;
#X connect 14 0 16 0;
#X connect 15 0 25 0;
#X connect 16 0 13 0;
#X connect 16 1 35 0;
#X connect 16 2 36 0;
#X connect 16 3 37 0;
#X connect 16 4 39 0;
#X connect 16 4 55 0;
#X connect 17 0 16 0;
#X connect 19 0 23 0;
#X connect 19 1 24 0;
#X connect 20 0 19 0;
#X connect 21 0 20 0;
#X connect 22 0 20 0;
#X connect 25 0 44 0;
#X connect 26 0 27 0;
#X connect 27 0 25 0;
#X connect 29 0 43 0;
#X connect 30 0 29 0;
#X connect 31 0 6 0;
#X connect 32 0 9 0;
#X connect 33 0 32 0;
#X connect 34 0 51 0;
#X connect 35 0 52 0;
#X connect 36 0 53 0;
#X connect 37 0 54 0;
#X connect 39 0 38 0;
#X connect 42 0 16 0;
#X connect 48 0 16 0;
#X connect 49 0 16 0;
#X connect 50 0 16 0;
#X restore 725 508 pd special-selectors/message-types;
#X text 21 573 see also:;
#X obj 99 574 select;
#X text 558 355 In the case of messages that start with a symbol \, the first element is also known as the 'selector' of the message. Hence \, [route] trims the selector of the message when it matches one of its symbol arguments., f 62;
#X listbox 166 277 8 0 0 0 - - - 0;
#X floatatom 244 275 5 0 0 0 - - - 0;
#X obj 332 275 list;
#X listbox 332 299 8 0 0 0 - - - 0;
#X obj 411 274 list;
#X listbox 411 298 14 0 0 0 - - - 0;
#X obj 185 466 list;
#X listbox 185 490 10 0 0 0 - - - 0;
#X obj 276 466 list;
#X listbox 276 490 10 0 0 0 - - - 0;
#X obj 369 467 list;
#X listbox 369 491 20 0 0 0 - - - 0;
#X obj 596 301 print f1;
#X obj 663 301 print f2;
#X listbox 596 272 7 0 0 0 - - - 0;
#X listbox 663 272 7 0 0 0 - - - 0;
#X obj 802 260 symbol;
#X symbolatom 802 284 7 0 0 0 - - - 0;
#X obj 868 260 list;
#X listbox 868 284 10 0 0 0 - - - 0;
#X msg 858 152 symbol hi;
#X text 574 70 If no argument is given \, [route] loads a float argument of 0 and creates a second inlet so you can change the argument value (to another float). In the same way \, a single symbol argument adds an inlet that expects a symbol message to change the argument., f 59;
#X obj 5 45 cnv 1 1020 1 empty empty empty 8 12 0 13 #000000 #000000 0;
#X obj 5 558 cnv 1 1020 1 empty empty empty 8 12 0 13 #000000 #000000 0;
#N canvas 752 101 565 441 reference 0;
#X obj 4 46 cnv 5 550 5 empty empty INLETS: 8 18 0 13 #202020 #000000 0;
#X obj 4 216 cnv 2 550 2 empty empty OUTLETS: 8 12 0 13 #202020 #000000 0;
#X obj 4 370 cnv 2 550 2 empty empty ARGUMENTS: 8 12 0 13 #202020 #000000 0;
#X obj 3 415 cnv 5 550 5 empty empty empty 8 18 0 13 #202020 #000000 0;
#X obj 4 78 cnv 1 550 1 empty empty 1st: 8 12 0 13 #7c7c7c #000000 0;
#X obj 2 107 cnv 1 550 1 empty empty 2nd: 8 12 0 13 #7c7c7c #000000 0;
#X obj 4 247 cnv 1 550 1 empty empty n: 8 12 0 13 #7c7c7c #000000 0;
#X text 77 220 (depends on the number of arguments);
#X obj 4 287 cnv 1 550 1 empty empty rightmost: 8 12 0 13 #7c7c7c #000000 0;
#X text 112 315 when input doesn't match the arguments \, it is passed here., f 59;
#X obj 27 13 route;
#X text 81 14 - trim first element and route messages according to it.;
#X text 94 83 anything - any message to route according to the first element., f 63;
#X text 94 258 anything - routed message with the first element trimmed., f 63;
#X text 34 315 anything -;
#X text 90 138 float -;
#X text 83 161 symbol -;
#X text 149 161 replaces single symbol argument (if given)., f 47;
#X text 149 138 replaces single float argument (if given)., f 47;
#X text 101 383 1) list - of floats or symbols to route to (default 0).;
#X text 41 110 (only created if a single argument is given);
#X restore 851 14 pd reference;
#X text 949 14 <= click;
#X obj 596 243 route, f 10;
#X text 17 56 The [route] object checks a message's first element against its arguments \, which may be numbers or symbols (but not a mixture of the two). If a match is found \, the rest of the message appears on the corresponding outlet. If there's no match \, the message is repeated to the last "rejection" outlet. The number of outlets is the number of arguments plus one., f 74;
#X msg 663 166 1;
#X msg 671 192 4;
#X text 559 426 There are exceptions though when we're dealing with special selectors that Pd deals with \, namely: list \, float \, symbol and bang. One byproduct of [route] is that it can also be used to route messages according to these types. Open the subpatch below for details, f 62;
#X connect 3 0 37 0;
#X connect 3 1 38 0;
#X connect 3 2 39 0;
#X connect 3 2 2 0;
#X connect 3 3 23 0;
#X connect 3 3 41 0;
#X connect 4 0 3 0;
#X connect 5 0 3 0;
#X connect 6 0 3 0;
#X connect 7 0 3 0;
#X connect 8 0 9 0;
#X connect 9 0 16 0;
#X connect 9 0 43 0;
#X connect 9 1 17 0;
#X connect 9 1 45 0;
#X connect 9 2 24 0;
#X connect 9 2 47 0;
#X connect 10 0 9 0;
#X connect 11 0 9 0;
#X connect 12 0 9 0;
#X connect 13 0 3 0;
#X connect 20 0 63 0;
#X connect 21 0 63 1;
#X connect 22 0 63 0;
#X connect 25 0 30 0;
#X connect 25 0 53 0;
#X connect 25 1 31 0;
#X connect 25 1 55 0;
#X connect 26 0 25 0;
#X connect 27 0 25 0;
#X connect 28 0 25 1;
#X connect 29 0 28 0;
#X connect 37 0 0 0;
#X connect 38 0 1 0;
#X connect 39 0 40 0;
#X connect 41 0 42 0;
#X connect 43 0 44 0;
#X connect 45 0 46 0;
#X connect 47 0 48 0;
#X connect 51 0 49 0;
#X connect 52 0 50 0;
#X connect 53 0 54 0;
#X connect 55 0 56 0;
#X connect 57 0 28 0;
#X connect 63 0 51 0;
#X connect 63 1 52 0;
#X connect 65 0 21 0;
#X connect 66 0 21 0;
