| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Scripting 6.3. Query commands</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.3. Query commands |
| 13 | </b></font></table></table> |
| 14 | <p>If you click the <b>Get mean...</b> command for a Pitch object, the Info window will contain a text like “150 Hz” as a result. In a script, you would rather have this result in a variable instead of in the Info window. The solution is simple:</p> |
| 15 | <code> mean = Get mean: 0, 0, “Hertz”, “Parabolic”<br></code> |
| 16 | <p>The numeric variable <i>mean</i> now contains the number 150. When assigning to a numeric variable, the interpreter converts the part of the text before the first space into a number.</p> |
| 17 | <p>You can also assign to string variables:</p> |
| 18 | <code> mean$ = Get mean: 0, 0, “Hertz\", “Parabolic”<br></code> |
| 19 | <p>The string variable <i><code><font size=+1>mean$</font></code></i> now contains the entire string “150 Hz”.</p> |
| 20 | <p>This works for every command that would otherwise write into the Info window.</p> |
| 21 | <h3>Links to this page</h3> |
| 22 | <ul> |
| 23 | <li><a href="Query_submenu.html">Query submenu</a> |
| 24 | <li><a href="Scripting.html">Scripting</a> |
| 25 | <li><a href="Scripting_5_2__Expressions.html">Scripting 5.2. Expressions</a> |
| 26 | <li><a href="Scripting_6__Communication_outside_the_script.html">Scripting 6. Communication outside the script</a> |
| 27 | </ul> |
| 28 | <hr> |
| 29 | <address> |
| 30 | <p>© Paul Boersma 2014-01-07</p> |
| 31 | </address> |
| 32 | </body> |
| 33 | </html> |