selected#

A function that can be used in Formulas.

## Syntax and semantics

`selected#` ( )
  return a list of the IDs of all currently selected objects.
`selected#` (`type$`)
  return a list of the IDs of all currently selected objects of type `type$`.

## Example

Assume that at the start of the following script, the list of objects is empty:

`sound = Create Sound from formula: "sine377", 1, 0, 0.1, 44100,
` `... ~ sin (2*pi*377*x)
` `pitch = To Pitch: 0.01, 75, 600
` `plusObject: sound
` `pulses = To PointProcess (cc)
` `plusObject: sound
`

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:

`1. Sound sine377
` `2. Pitch sine377
` `3. PointProcess sine377_sine377
`

The IDs of the two selected objects are 1 and 3, respectively, and this is what `selected#` ( ) will show:

`writeInfoLine: selected# ()
` `=>`
`1 3
`

We can also just list the selected Sound objects:

`writeInfoLine: selected# ("Sound")
` `=>`
`1
`

or the selected Pitch objects (there should be none):

`writeInfoLine: selected# ("Pitch")
` `=>`
`
`

or the selected PointProcess objects:

`writeInfoLine: selected# ("PointProcess")
` `=>`
`3
`

## Test

An automated test:

`assert selected# () = { 1, 3 }
` `assert selected# ("Sound") = { 1 }
` `assert selected# ("Pitch") = zero# (0)
` `assert selected# ("PointProcess") = { 3 }
`

### Links to this page

- `selected$#`
- Functions
- Scripting 4.3. Querying objects