| 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 full names 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 given names of all currently selected objects of type <i><code><font size=+1>type$</font></code></i>.</dd> |
| 21 |
</dl> |
| 22 |
<h2>Pitfall</h2> |
| 23 |
<p>You cannot normally use this function to cycle through all selected objects, because if two objects happen to have the same full name, you will select the same object twice. To cycle through all selected objects, use <a href="_selected-H_.html"><b><code><font size=+1>selected#</font></code></b></a> instead, because the IDs are guaranteed to be unique.</p> |
| 24 |
<h2>Example</h2> |
| 25 |
<p>Assume that at the start of the following script, the list of objects is empty:</p> |
| 26 |
<code> sound = Create Sound from formula: "sine377", 1, 0, 0.1, 44100,<br></code> |
| 27 |
<code> ... ~ sin (2*pi*377*x)<br></code> |
| 28 |
<code> pitch = To Pitch: 0.01, 75, 600<br></code> |
| 29 |
<code> plusObject: sound<br></code> |
| 30 |
<code> pulses = To PointProcess (cc)<br></code> |
| 31 |
<code> plusObject: sound<br></code> |
| 32 |
<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> |
| 33 |
<code> <b>1. Sound sine377</b><br></code> |
| 34 |
<code> 2. Pitch sine377<br></code> |
| 35 |
<code> <b>3. PointProcess sine377_sine377</b><br></code> |
| 36 |
<p>The full names of the two selected objects are <code><font size=+1>Sound sine377</font></code> and <code><font size=+1>PointProcess sine377_sine377</font></code>, respectively, and this is what <code><font size=+1>selected$#</font></code> ( ) will show:</p> |
| 37 |
<code> writeInfoLine: <b>selected$#</b> ()<br></code> |
| 38 |
<code style="color:red">=></code><br> |
| 39 |
<code> Sound sine377 PointProcess sine377_sine377<br></code> |
| 40 |
<p>or</p> |
| 41 |
<code> writeInfoLine: vertical$: <b>selected$#</b> ()<br></code> |
| 42 |
<code style="color:red">=></code><br> |
| 43 |
<code> Sound sine377<br></code> |
| 44 |
<code> PointProcess sine377_sine377<br></code> |
| 45 |
<p>We can also just list the given names of the selected Sound objects:</p> |
| 46 |
<code> writeInfoLine: <b>selected$#</b> ("Sound")<br></code> |
| 47 |
<code style="color:red">=></code><br> |
| 48 |
<code> sine377<br></code> |
| 49 |
<p>or of the selected Pitch objects (there should be none):</p> |
| 50 |
<code> writeInfoLine: <b>selected$#</b> ("Pitch")<br></code> |
| 51 |
<code style="color:red">=></code><br> |
| 52 |
<code> <br></code> |
| 53 |
<p>or of the selected PointProcess objects:</p> |
| 54 |
<code> writeInfoLine: <b>selected$#</b> ("PointProcess")<br></code> |
| 55 |
<code style="color:red">=></code><br> |
| 56 |
<code> sine377_sine377<br></code> |
| 57 |
<p>Note that here we see only the given names (not the full names), because the type names are already known.</p> |
| 58 |
<h2>Test</h2> |
| 59 |
<p>An automated test:</p> |
| 60 |
<code> <a href="_assert_.html">assert</a> <b>selected$#</b> () = { “Sound sine377”,<br></code> |
| 61 |
<code> ... “PointProcess sine377_sine377” }<br></code> |
| 62 |
<code> <a href="_assert_.html">assert</a> <b>selected$#</b> ("Sound") = { “sine377” }<br></code> |
| 63 |
<code> <a href="_assert_.html">assert</a> <b>selected$#</b> ("Pitch") = empty$# (0)<br></code> |
| 64 |
<code> <a href="_assert_.html">assert</a> <b>selected$#</b> ("PointProcess") = { “sine377_sine377” }<br></code> |
| 65 |
<h3>Links to this page</h3> |
| 66 |
<ul> |
| 67 |
<li><a href="Functions.html">Functions</a> |
| 68 |
<li><a href="What_was_new_in_6_4_.html">What was new in 6.4?</a> |
| 69 |
</ul> |
| 70 |
<hr> |
| 71 |
<address> |
| 72 |
<p>© Paul Boersma 2023</p> |
| 73 |
</address> |
| 74 |
</body> |
| 75 |
</html> |