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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
#N canvas 526 75 562 611 10;
#X obj 3 405 cnv 3 550 3 empty empty inlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 3 466 cnv 3 550 3 empty empty outlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 3 499 cnv 3 550 3 empty empty arguments 8 12 0 13 #dcdcdc #000000 0;
#X obj 75 412 cnv 17 3 17 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X obj 75 475 cnv 17 3 17 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X obj 51 281 print;
#X obj 3 590 cnv 15 552 21 empty empty empty 20 12 0 14 #e0e0e0 #202020 0;
#X text 173 507 -;
#X text 115 475 anything;
#X obj 21 201 bng 17 250 50 0 empty empty empty 17 7 0 10 #dcdcdc #000000 #000000;
#X text 139 413 bang;
#X text 115 436 anything;
#X text 172 435 -;
#X text 96 532 2) anything;
#X text 108 507 1) symbol;
#X text 173 532 -;
#X text 185 507 the optional 'symout' argument formats a symbol message ('symout' itself not included), f 57;
#X msg 198 201 wind;
#X msg 51 201 wood;
#X msg 272 163 64 64;
#X obj 51 240 cyclone/sprintf %s-%s.wav;
#X obj 328 163 nbx 3 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X text 172 413 - formats the message with current input, f 59;
#X obj 75 434 cnv 17 3 27 empty empty 0-n 5 9 0 16 #dcdcdc #9c9c9c 0;
#N canvas 749 189 489 533 possible-types 0;
#X text 91 66 %c;
#X text 112 66 character, f 49;
#X text 55 79 %d or %i;
#X text 91 118 %e;
#X text 91 131 %E;
#X text 91 170 %o;
#X text 91 183 %s;
#X text 91 196 %u;
#X text 112 196 unsigned integer, f 49;
#X text 91 209 %x;
#X text 112 209 unsigned hexadecimal in lowercase, f 49;
#X text 91 222 %X;
#X text 112 222 unsigned hexadecimal in CAPS, f 49;
#X text 112 170 unsigned octal, f 49;
#X text 112 183 string, f 49;
#X text 91 144 %g;
#X text 91 157 %G;
#X text 91 105 %F;
#X text 91 92 %f;
#X obj 50 319 pdcontrol;
#X msg 50 290 browse https://en.wikipedia.org/wiki/Printf_format_string;
#X text 57 12 Possible types in [sprintf], f 30;
#X text 112 79 signed decimal intege, f 49;
#X text 112 92 float (lowercase for 'nan'/'inf'), f 49;
#X text 112 105 float (uppercase for 'NAN'/'INF'), f 49;
#X text 112 118 float in exponential notation using "e" character;
#X text 112 131 float in exponential notation using "E" character;
#X text 112 144 float in normal (%f) or exponential (%e), f 49;
#X text 112 157 float in normal (%F) or exponential (%E), f 49;
#X text 74 257 For more details on these types \, refer to a standard C library manual. For instance in the link below:, f 52;
#X obj 50 261 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X text 91 42 %a;
#X text 91 54 %A;
#X text 112 42 float hexadecimal in lowercase, f 49;
#X text 112 54 float hexadecimal in CAPS, f 49;
#X text 137 320 The above reference has more information and parameters not really available for [sprintf]. Nonetheless \, the length modifiers \, the optional flags: "+" \, " " \, "-" and "#" \, plus the width and precision fields are supported., f 47;
#X text 35 387 Inconsistencies: If a format type is not supported or invalid \, [sprintf] doesn't create a corresponding inlet and prints an error isntead. The Max version creates an inlet for whatever inserted type \, invalid or not \, and only prints an error when trying to convert. The MAX original also doesn't support the "space" flag or %a/%A types. The length modifiers are supported but since Pd does not have an integer type \, something like '%lld' won't work with full precision even if you're using Pd compiled for double precision (aka Pd64). Also \, some values for a format like '%u' will only actually be possible to represent in Pd64 because they can exceed the 2ˆ24 limit of 32-bit float., f 64;
#X connect 20 0 19 0;
#X connect 30 0 20 0;
#X restore 335 562 pd possible-types;
#X text 185 532 output message with format types '%' (each changeable argument creates a corresponding inlet). For all possible types and details \, see:;
#X text 184 435 float/symbol to match corresponding given type. Messages with more than one item spraed items to the next inlets.;
#X text 23 63 Message formatter;
#X text 67 336 see also:;
#X obj 426 369 open-else;
#X text 478 340 click;
#X obj 59 358 makefilename;
#X msg 426 341 format;
#X obj 3 4 ./header sprintf;
#X obj 272 219 cyclone/sprintf list char number %d is '%c';
#X listbox 272 250 24 0 0 0 - - - 0;
#X text 75 87 Based on C's "printf" function \, [sprintf] formats messages \, where each '%' format type corresponds to an inlet. By default you have each argument as a separate element in a message \, but the 'symout' argument creates a symbol out of everything., f 66;
#X text 172 475 - the formatted message as a series of atoms or a symbol;
#X text 153 349 Plugdata users or those with ELSE can also use [else/format] as an alternative., f 42;
#X obj 239 163 bng 17 250 50 0 empty empty empty 17 7 0 10 #dcdcdc #000000 #000000;
#X obj 328 190 trigger float float;
#N canvas 631 78 781 745 more 0;
#X obj 61 276 print;
#X obj 61 181 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 61 458 print;
#X msg 61 392 error;
#X obj 240 424 cyclone/sprintf it's %s;
#X msg 240 392 OK!;
#X obj 240 458 print;
#X text 50 152 Examples with float:;
#X obj 61 424 cyclone/sprintf %d;
#X text 34 320 A symbol may be received in any inlet that corresponds to a %s argument. If sent to another inlet type \, a conversion error is given in Pd's window.;
#X msg 523 310 a;
#X floatatom 598 310 5 0 0 0 - - - 0;
#X symbolatom 523 425 15 0 0 0 - - - 0;
#X symbolatom 640 426 13 0 0 0 - - - 0;
#X obj 523 398 unpack symbol symbol;
#X obj 523 335 cyclone/bondo;
#X obj 523 361 cyclone/sprintf list %s\ symbol %d\ int, f 20;
#X symbolatom 489 168 10 0 0 0 - - - 0;
#X msg 489 112 a;
#X obj 489 142 cyclone/sprintf symout %s symbol, f 34;
#X obj 489 197 print;
#X symbolatom 468 310 7 0 0 0 - - - 0;
#X text 21 90 If a changeable number argument argument (such as %i or %f) does not receive an input \, the default value is "0". If no value has been received for a changeable symbol argument (%s or %c) \, a blank space is the default., f 64;
#X text 252 248 %% becomes %;
#X text 174 265 %%%% becomes %% and so on;
#X msg 203 501 is;
#X obj 203 561 print;
#X msg 205 184 10.6;
#X text 241 183 (truncated to int);
#X floatatom 167 184 5 0 0 0 - - - 0;
#X obj 205 216 t b f;
#X obj 203 528 cyclone/sprintf this %s %s %s;
#X msg 288 501 quite alright;
#X obj 130 624 makefilename;
#X obj 61 246 cyclone/sprintf %.2fdB a-%i%%;
#X text 76 647 for more details on supported specifiers \, as most of them are shared between the two objects., f 21;
#X text 76 602 See the help file of, f 12;
#X obj 456 453 bng 19 250 50 0 empty empty empty 0 -8 0 10 #dfdfdf #000000 #000000;
#X listbox 456 546 13 0 0 0 - - - 12;
#X text 560 548 *;
#X obj 456 512 cyclone/sprintf symout %u;
#X text 21 16 The arguments in [sprintf] format a message to be sent out and can be floats and symbols with or without changeable arguments (like %i for integers \, %f for floats and %s for symbol strings) resembling the C programming language. The number of changeable arguments determines the number of inlets \, with each inlet corresponding to a changeable argument \, in order., f 64;
#X text 35 514 Messages with more than one item spreads items to the next inlets., f 23;
#X text 434 20 The optional 'symout' argument turns the whole output into a symbol message \, which is useful for format strings with spaces \, commas and other special characters. In this case you should not use backslash \, as it is common in Pd to escape a space or another special symbol., f 48;
#X text 452 241 Nonetheless \, note you can use backslashes to create symbols with special characters such as spaces without the 'symout' argument., f 44;
#X text 281 643 The MAX original has issues in dealing with spaces for symbol input that contains spaces. Similarly \, there are also issues with the width field when it adds spaces and the 'space' flag. What happens is that atoms get split by the spaces when you don't have the 'symout' argument. The cyclone version also has the same issues., f 72;
#X obj 456 483 expr pow(2 \, 32) - 2;
#X text 421 576 * The correct exact result ('4294967294') is only possible in Pd compiled with double precision (aka Pd64), f 43;
#X connect 1 0 34 0;
#X connect 3 0 8 0;
#X connect 4 0 6 0;
#X connect 5 0 4 0;
#X connect 8 0 2 0;
#X connect 10 0 15 0;
#X connect 11 0 15 1;
#X connect 14 0 12 0;
#X connect 14 1 13 0;
#X connect 15 0 16 0;
#X connect 15 1 16 1;
#X connect 16 0 14 0;
#X connect 17 0 20 0;
#X connect 18 0 19 0;
#X connect 19 0 17 0;
#X connect 21 0 15 0;
#X connect 25 0 31 0;
#X connect 27 0 30 0;
#X connect 29 0 30 0;
#X connect 30 0 34 0;
#X connect 30 1 34 1;
#X connect 31 0 26 0;
#X connect 32 0 31 1;
#X connect 34 0 0 0;
#X connect 37 0 46 0;
#X connect 40 0 38 0;
#X connect 46 0 40 0;
#X restore 387 295 pd more examples;
#X obj 272 281 print;
#X connect 9 0 20 0;
#X connect 17 0 20 1;
#X connect 18 0 20 0;
#X connect 19 0 34 0;
#X connect 20 0 5 0;
#X connect 21 0 40 0;
#X connect 32 0 29 0;
#X connect 34 0 35 0;
#X connect 35 0 42 0;
#X connect 39 0 34 0;
#X connect 40 0 34 0;
#X connect 40 1 34 1;
|