str-help.pd 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #N canvas 93 115 450 300 10;
  2. #N canvas 32 72 706 515 string 0;
  3. #X obj 88 454 print;
  4. #X obj 143 328 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
  5. -1 -1;
  6. #X floatatom 37 53 5 0 0 0 - - -;
  7. #X obj 88 387 str hello 32 there 10 no more;
  8. #X obj 16 7 str nono 32 pitek;
  9. #X obj 16 -15 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  10. -1;
  11. #X obj 88 429 str to_list;
  12. #X obj 67 123 symbol tikka;
  13. #X obj 67 100 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  14. -1;
  15. #X msg 117 218 str 2;
  16. #X text 174 430 str to_list outputs the string as a list of floats.
  17. ;
  18. #X text 299 378 str string (the default) converts nearly anything to
  19. a string.;
  20. #X msg 100 190 set one 2;
  21. #X msg 82 155 list 1 2 3 alpha;
  22. #X text 80 51 Whole numbers from -127 through 255 are converted to
  23. single bytes. All others are formatted as floats using ASCII characters.
  24. ;
  25. #X text 173 190 Set the string quietly;
  26. #X floatatom 130 29 5 0 0 0 - - -;
  27. #X text 165 0 The basic [str] or [str string] outputs a string on its
  28. left outlet and the length of the string at the reight outlet.;
  29. #X floatatom 286 410 5 0 0 0 - - -;
  30. #X msg 127 260 file_read test.txt;
  31. #X text 159 124 Symbols are interpreted as text strings.;
  32. #X text 210 156 List elements are converted to numbers or strings.
  33. ;
  34. #X text 167 215 Messages other than [list ...( or [set ...( are transcribed
  35. directly.;
  36. #X msg 136 282 file_write test.txt;
  37. #X text 265 261 String data can be stored in and retrieved from files.
  38. ;
  39. #X text 163 327 [Bang] generates output.;
  40. #X connect 1 0 3 0;
  41. #X connect 2 0 3 0;
  42. #X connect 3 0 6 0;
  43. #X connect 3 1 18 0;
  44. #X connect 4 0 3 0;
  45. #X connect 4 1 16 0;
  46. #X connect 5 0 4 0;
  47. #X connect 6 0 0 0;
  48. #X connect 7 0 3 0;
  49. #X connect 8 0 7 0;
  50. #X connect 9 0 3 0;
  51. #X connect 12 0 3 0;
  52. #X connect 13 0 3 0;
  53. #X connect 19 0 3 0;
  54. #X connect 23 0 3 0;
  55. #X restore 3 31 pd string;
  56. #N canvas 259 148 678 300 split 0;
  57. #X obj 67 101 str to_list;
  58. #X obj 174 100 str to_list;
  59. #X obj 67 126 print left;
  60. #X obj 174 125 print right;
  61. #X obj 95 55 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  62. -1;
  63. #X obj 95 79 str nsplit 6;
  64. #X floatatom 174 55 5 0 0 0 - - -;
  65. #X text 192 79 [str nsplit] splits a string in two at the nth character.
  66. ;
  67. #X msg 42 31 set microscope;
  68. #X obj 75 244 str to_list;
  69. #X obj 156 244 str to_list;
  70. #X obj 75 269 print left;
  71. #X obj 156 269 print right;
  72. #X obj 142 193 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
  73. -1 -1;
  74. #X obj 142 218 str csplit 32;
  75. #X msg 65 170 what 32 are 32 you 10 13;
  76. #X msg 176 193 set t 32;
  77. #X text 251 193 Set the target character(s);
  78. #X text 244 217 [str csplit] splits incoming strings in two at the
  79. first occurrence of any of the characters in its string. The second
  80. string begins with the first remaining non-target character.;
  81. #X text 153 31 Quietly set the string to be split;
  82. #X text 219 54 Split position: positive from start \, negative from
  83. end;
  84. #X text 252 11 Split this string;
  85. #X msg 6 10 10 11 12 13 14 15 16 17 18 19 20;
  86. #X connect 0 0 2 0;
  87. #X connect 1 0 3 0;
  88. #X connect 4 0 5 0;
  89. #X connect 5 0 0 0;
  90. #X connect 5 1 1 0;
  91. #X connect 6 0 5 1;
  92. #X connect 8 0 5 0;
  93. #X connect 9 0 11 0;
  94. #X connect 10 0 12 0;
  95. #X connect 13 0 14 0;
  96. #X connect 14 0 9 0;
  97. #X connect 14 1 10 0;
  98. #X connect 15 0 14 0;
  99. #X connect 16 0 14 0;
  100. #X connect 22 0 5 0;
  101. #X restore 3 66 pd split;
  102. #N canvas 273 114 640 400 join 0;
  103. #X obj 48 60 str join pig;
  104. #X obj 48 108 str to_list;
  105. #X obj 206 -4 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  106. -1;
  107. #X obj 13 -32 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  108. -1;
  109. #X obj 198 15 str 32 the 32 end;
  110. #X obj 13 -13 str This 32 is;
  111. #X msg 10 31 set That 32 was;
  112. #X floatatom 198 -27 5 0 0 0 - - -;
  113. #X obj 48 130 print joined;
  114. #X obj 10 51 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  115. -1;
  116. #X text 175 60 [str join]: Set the string to be appended either with
  117. a [set( message to the first inlet or by sending a string to the second
  118. inlet.;
  119. #X msg 43 -34 elephant;
  120. #X floatatom 106 7 5 0 0 0 - - -;
  121. #X floatatom 312 36 5 0 0 0 - - -;
  122. #X floatatom 127 82 5 0 0 0 - - -;
  123. #X obj 43 259 str add abc;
  124. #X floatatom 43 217 5 0 0 0 - - -;
  125. #X obj 17 233 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  126. -1;
  127. #X obj 43 303 str to_list;
  128. #X obj 115 200 str;
  129. #X floatatom 88 159 5 0 0 0 - - -;
  130. #X msg 115 176 whoa;
  131. #X msg 55 236 set;
  132. #X text 84 237 [set( message without arguments clears the string.;
  133. #X text 133 259 [str add] adds input to the end of the string until
  134. banged.;
  135. #X floatatom 129 221 5 0 0 0 - - -;
  136. #X floatatom 115 282 5 0 0 0 - - -;
  137. #X text 158 282 string length;
  138. #X obj 43 324 print added;
  139. #X connect 0 0 1 0;
  140. #X connect 0 1 14 0;
  141. #X connect 1 0 8 0;
  142. #X connect 2 0 4 0;
  143. #X connect 3 0 5 0;
  144. #X connect 4 0 0 1;
  145. #X connect 4 1 13 0;
  146. #X connect 5 0 0 0;
  147. #X connect 5 1 12 0;
  148. #X connect 6 0 0 0;
  149. #X connect 7 0 4 0;
  150. #X connect 9 0 0 0;
  151. #X connect 11 0 0 0;
  152. #X connect 15 0 18 0;
  153. #X connect 15 1 26 0;
  154. #X connect 16 0 15 0;
  155. #X connect 17 0 15 0;
  156. #X connect 18 0 28 0;
  157. #X connect 19 0 15 1;
  158. #X connect 19 1 25 0;
  159. #X connect 20 0 19 0;
  160. #X connect 21 0 19 0;
  161. #X connect 22 0 15 0;
  162. #X restore 3 99 pd join;
  163. #X text 61 98 join and add;
  164. #N canvas 0 0 771 248 compare 0;
  165. #X obj 16 130 str compare This 32 is 32 the 32 end;
  166. #X floatatom 16 153 5 0 0 0 - - -;
  167. #X text 276 131 [str compare]: Set the reference string either with
  168. a [set( message to the first inlet or by sending a string to the second
  169. inlet.;
  170. #X msg 67 102 set This 32 is That 32 was;
  171. #X obj 263 62 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  172. -1;
  173. #X obj 263 81 str 32 the 32 end;
  174. #X floatatom 377 102 5 0 0 0 - - -;
  175. #X text 19 179 Output is 1 only if the input string and the reference
  176. string are identical.;
  177. #X obj 30 37 str This 32 is 32 the 32 end;
  178. #X obj 30 15 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  179. -1;
  180. #X msg 37 64 32 the 32 end;
  181. #X obj 45 103 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
  182. -1;
  183. #X connect 0 0 1 0;
  184. #X connect 3 0 0 0;
  185. #X connect 4 0 5 0;
  186. #X connect 5 0 0 1;
  187. #X connect 5 1 6 0;
  188. #X connect 8 0 0 0;
  189. #X connect 9 0 8 0;
  190. #X connect 10 0 0 0;
  191. #X connect 11 0 0 0;
  192. #X restore 4 135 pd compare;
  193. #X text 84 134 compare two strings;
  194. #N canvas -4 -4 399 531 conversion 0;
  195. #X obj 19 16 bng 15 250 50 0 empty empty empty 17 7 0 10 -24198 -250685
  196. -1;
  197. #X obj 19 80 print;
  198. #X obj 19 52 str to_symbol whichever 32 was it;
  199. #X floatatom 47 16 5 0 0 0 - - -;
  200. #X obj 22 152 str to_float 189.999;
  201. #X floatatom 22 181 15 0 0 0 - - -;
  202. #X obj 22 118 bng 15 250 50 0 empty empty empty 17 7 0 10 -24198 -250685
  203. -1;
  204. #X floatatom 48 118 5 0 0 0 - - -;
  205. #X msg 90 16 whatever I thought32 at 32 the 10 32 time;
  206. #X msg 97 121 192.168.0.1;
  207. #X msg 110 89 all32were wolves;
  208. #X text 167 152 [str to_float] converts as much as possible of a string
  209. to a single float.;
  210. #X text 257 53 [str to_symbol] converts a string to a symbol as best
  211. it can.;
  212. #X obj 24 261 print;
  213. #X obj 24 236 str to_list;
  214. #X msg 24 212 tell 32 me 32 everything 10 13;
  215. #X text 112 235 [str to_list] outputs the string as a list of floats.
  216. ;
  217. #X msg 30 299 One 32 at 32 a 32 time 10 13;
  218. #X obj 30 347 print;
  219. #X obj 30 323 str drip trip 10 13;
  220. #X obj -13 269 bng 15 250 50 0 empty empty empty 17 7 0 10 -24198 -250685
  221. -1;
  222. #X floatatom 80 259 5 0 0 0 - - -;
  223. #X floatatom 83 349 5 0 0 0 - - -;
  224. #X obj 158 345 bng 15 250 50 0 empty empty empty 17 7 0 10 -24198 -250685
  225. -1;
  226. #X obj 180 345 tgl 15 0 empty empty empty 17 7 0 10 -24198 -250685
  227. -1 0 1;
  228. #X floatatom 118 432 5 0 0 0 - - -;
  229. #X msg 29 377 The nth character of this string will be output as a
  230. float 10 13;
  231. #X obj 60 450 str nth 5;
  232. #X obj 22 422 bng 15 250 50 0 empty empty empty 17 7 0 10 -24198 -250685
  233. -1;
  234. #X msg 98 410 set one;
  235. #X text 160 411 [set( quietly sets the string to be analyzed.;
  236. #X floatatom 118 490 5 0 0 0 - - -;
  237. #X text 161 489 string length;
  238. #X floatatom 60 491 5 0 0 0 - - -;
  239. #X text 128 451 [str nth] emits the nth character if it exists \, otherwise
  240. a bang will be emitted.;
  241. #X text 162 431 set n;
  242. #X text 202 322 [str drip] outputs the entire string one float at a
  243. time. Outlet 2 bangs when end is reached.;
  244. #X obj -12 289 until;
  245. #X connect 0 0 2 0;
  246. #X connect 2 0 1 0;
  247. #X connect 3 0 2 0;
  248. #X connect 4 0 5 0;
  249. #X connect 6 0 4 0;
  250. #X connect 7 0 4 0;
  251. #X connect 8 0 2 0;
  252. #X connect 9 0 4 0;
  253. #X connect 10 0 4 0;
  254. #X connect 14 0 13 0;
  255. #X connect 14 0 21 0;
  256. #X connect 15 0 14 0;
  257. #X connect 17 0 19 0;
  258. #X connect 19 0 18 0;
  259. #X connect 19 0 22 0;
  260. #X connect 19 1 23 0;
  261. #X connect 19 1 37 1;
  262. #X connect 20 0 37 0;
  263. #X connect 23 0 24 0;
  264. #X connect 25 0 27 1;
  265. #X connect 26 0 27 0;
  266. #X connect 27 0 33 0;
  267. #X connect 27 1 31 0;
  268. #X connect 28 0 27 0;
  269. #X connect 29 0 27 0;
  270. #X connect 37 0 19 0;
  271. #X restore 4 172 pd conversion;
  272. #X text 105 171 convert strings to other pd types;
  273. #X text 75 30 the basic string;
  274. #X text 69 65 split strings by character or position;