| 1 |
<html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 |
<title>selected#</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="Monaco,Courier" size=6 color="#999900"><b> |
| 12 |
selected# |
| 13 |
</b></font></table></table> |
| 14 |
<p>A function that can be used in <a href="Formulas.html">Formulas</a>.</p> |
| 15 |
<h2>Syntax and semantics</h2> |
| 16 |
<dl> |
| 17 |
<dt><b><code><font size=+1>selected#</font></code></b> ( ) |
| 18 |
<dd>return a list of the IDs of all currently selected objects.</dd> |
| 19 |
<dt><b><code><font size=+1>selected#</font></code></b> (<i><code><font size=+1>type$</font></code></i>) |
| 20 |
<dd>return a list of the IDs of all currently selected objects of type <i><code><font size=+1>type$</font></code></i>.</dd> |
| 21 |
</dl> |
| 22 |
<h2>Example</h2> |
| 23 |
<p>Assume that at the start of the following script, the list of objects is empty:</p> |
| 24 |
<code> sound = Create Sound from formula: "sine377", 1, 0, 0.1, 44100,<br></code> |
| 25 |
<code> ... ~ sin (2*pi*377*x)<br></code> |
| 26 |
<code> pitch = To Pitch: 0.01, 75, 600<br></code> |
| 27 |
<code> plusObject: sound<br></code> |
| 28 |
<code> pulses = To PointProcess (cc)<br></code> |
| 29 |
<code> plusObject: sound<br></code> |
| 30 |
<p>At this point, the list of objects will contain three objects, which will look as follows (ID, type name, given name), where the two that stand selected are given in bold:</p> |
| 31 |
<code> <b>1. Sound sine377</b><br></code> |
| 32 |
<code> 2. Pitch sine377<br></code> |
| 33 |
<code> <b>3. PointProcess sine377_sine377</b><br></code> |
| 34 |
<p>The IDs of the two selected objects are 1 and 3, respectively, and this is what <code><font size=+1>selected#</font></code> ( ) will show:</p> |
| 35 |
<code> writeInfoLine: <b>selected#</b> ()<br></code> |
| 36 |
<code style="color:red">=></code><br> |
| 37 |
<code> 1 3<br></code> |
| 38 |
<p>We can also just list the selected Sound objects:</p> |
| 39 |
<code> writeInfoLine: <b>selected#</b> ("Sound")<br></code> |
| 40 |
<code style="color:red">=></code><br> |
| 41 |
<code> 1<br></code> |
| 42 |
<p>or the selected Pitch objects (there should be none):</p> |
| 43 |
<code> writeInfoLine: <b>selected#</b> ("Pitch")<br></code> |
| 44 |
<code style="color:red">=></code><br> |
| 45 |
<code> <br></code> |
| 46 |
<p>or the selected PointProcess objects:</p> |
| 47 |
<code> writeInfoLine: <b>selected#</b> ("PointProcess")<br></code> |
| 48 |
<code style="color:red">=></code><br> |
| 49 |
<code> 3<br></code> |
| 50 |
<h2>Test</h2> |
| 51 |
<p>An automated test:</p> |
| 52 |
<code> <a href="_assert_.html">assert</a> <b>selected#</b> () = { 1, 3 }<br></code> |
| 53 |
<code> <a href="_assert_.html">assert</a> <b>selected#</b> ("Sound") = { 1 }<br></code> |
| 54 |
<code> <a href="_assert_.html">assert</a> <b>selected#</b> ("Pitch") = zero# (0)<br></code> |
| 55 |
<code> <a href="_assert_.html">assert</a> <b>selected#</b> ("PointProcess") = { 3 }<br></code> |
| 56 |
<h3>Links to this page</h3> |
| 57 |
<ul> |
| 58 |
<li><a href="_selected-S-H_.html"><code><font size=+1>selected$#</font></code></a> |
| 59 |
<li><a href="Functions.html">Functions</a> |
| 60 |
<li><a href="Scripting_4_3__Querying_objects.html">Scripting 4.3. Querying objects</a> |
| 61 |
</ul> |
| 62 |
<hr> |
| 63 |
<address> |
| 64 |
<p>© Paul Boersma 2023</p> |
| 65 |
</address> |
| 66 |
</body> |
| 67 |
</html> |