Debian Codegraph @

docs/manual/Scripting_6_8__Messages_to_the_user.html

raw symbols SCIP
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>Scripting 6.8. Messages to the user</title>
3 <style>
4 td { padding-left: 5pt; padding-right: 5pt; }
5 th { padding-left: 5pt; padding-right: 5pt; }
6 code { white-space: pre-wrap; }
7 dd { white-space: pre-wrap; }
8 </style>
9 </head><body bgcolor="#FFFFFF">
10
11 <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
12 Scripting 6.8. Messages to the user
13 </b></font></table></table>
14 <p>If the user makes a mistake (e.g. types conflicting settings into your form window), you can use the <b>exitScript</b> function (<a href="Scripting_5_9__Quitting.html">&#167;5.9</a>) to stop the execution of the script with an error message:</p>
15 <code> form: “My analysis”<br></code>
16 <code> real: “Starting time (s)”, “0.0”<br></code>
17 <code> real: “Finishing time (s)”, “1.0”<br></code>
18 <code> endform<br></code>
19 <code> if finishing_time &lt;= starting_time<br></code>
20 <code> <b>exitScript</b>: “The finishing time should exceed ”, starting_time, “ seconds.”<br></code>
21 <code> endif<br></code>
22 <code> # Proceed with the analysis...<br></code>
23 <p>For things that should not normally go wrong, you can use the <b><code><font size=+1>assert</font></code></b> directive:</p>
24 <code> power = Get power<br></code>
25 <code> assert power &gt; 0<br></code>
26 <p>This is the same as:</p>
27 <code> if (power &gt; 0) = undefined<br></code>
28 <code> exitScript: “Assertion failed in line ”, lineNumber, “ (undefined): power &gt; 0”<br></code>
29 <code> elsif not (power &gt; 0)<br></code>
30 <code> exitScript: “Assertion failed in line ”, lineNumber, “ (false): power &gt; 0”<br></code>
31 <code> endif<br></code>
32 <p>You can prevent Praat from issuing warning messages:</p>
33 <code> nowarn Save as WAV file: “hello.wav”<br></code>
34 <p>This prevents warning messages about clipped samples, for instance.</p>
35 <p>You can also prevent Praat from showing a progress window:</p>
36 <code> pitch = noprogress To Pitch: 0, 75, 500<br></code>
37 <p>This prevents the progress window from popping up during lengthy operations. Use this only if you want to prevent the user from stopping the execution of the script.</p>
38 <p>Finally, you can make Praat ignore error messages:</p>
39 <code> nocheck Remove<br></code>
40 <p>This would cause the script to continue even if there is nothing to remove.</p>
41 <h3>Links to this page</h3>
42 <ul>
43 <li><a href="_exitScript_.html"><code><font size=+1>exitScript</font></code></a>
44 <li><a href="Scripting.html">Scripting</a>
45 <li><a href="Scripting_6__Communication_outside_the_script.html">Scripting 6. Communication outside the script</a>
46 </ul>
47 <hr>
48 <address>
49 <p>© ppgb 20230122</p>
50 </address>
51 </body>
52 </html>