supernova: allocators - fix construct method
[supercollider.git] / Help / Streams-Patterns-Events / Patterns / Pprotect.html
blobc06ad4e817a283063c2dc88c7e84e765249885e2
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.41">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
16 span.s1 {font: 18.0px Helvetica}
17 span.s2 {color: #0000bf}
18 span.s3 {color: #606060}
19 span.s4 {color: #007300}
20 span.Apple-tab-span {white-space:pre}
21 </style>
22 </head>
23 <body>
24 <p class="p1"><span class="s1"><b>Pprotect<span class="Apple-tab-span"> </span></b></span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>evaluate a function when an error occured in the thread</b></p>
25 <p class="p2"><br></p>
26 <p class="p1">superclass: FilterPattern</p>
27 <p class="p2"><br></p>
28 <p class="p2"><br></p>
29 <p class="p1"><b>Pprotect(pattern func)</b></p>
30 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
31 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>pattern<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>any pattern</p>
32 <p class="p1"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>func<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span>the function to be evaluated when an error occurs.<span class="Apple-converted-space"> </span></p>
33 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>The error and the thread are passed as arguments to the function.<span class="Apple-tab-span"> </span></p>
34 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
35 <p class="p3"><br></p>
36 <p class="p4">// example</p>
37 <p class="p5"><br></p>
38 <p class="p6">(</p>
39 <p class="p6"><span class="s2">var</span> x;</p>
40 <p class="p6"><span class="s2">var</span> func = { <span class="s3">"an error happened"</span>.postln };</p>
41 <p class="p6">a = <span class="s2">Pprotect</span>(<span class="s2">Pseq</span>([1, 3, 3, <span class="s2">Pfuncn</span>({ <span class="s2">Error</span>.throw }), 2]), func);</p>
42 <p class="p6">x = <span class="s2">Pbind</span>(<span class="s4">\degree</span>, a, <span class="s4">\dur</span>, 0.5).play;</p>
43 <p class="p6">)</p>
44 </body>
45 </html>