Scripting 6.2. Writing to the Info window

With the Info button and several commands in the Query submenu (or with query commands in menus in the editors), you write to the Info window (if your program is run from the command line, the text goes to the console window or to stdout instead; see S6.9).

The commands writeInfo, writeInfoLine, appendInfo and appendInfoLine allow you to write to the Info window from a script. Those with write in their name clear the Info window before they write to it, those with append in their name do not. Those with Line in their name make sure that a following appendInfo or appendInfoLine will write on the next line.

These four functions take a variable number of numeric and/or string arguments, separated by commas. Here is an example:

writeInfoLine: “Pitch extrema:”
Create Sound as pure tone: “sine”, 1, 0, 0.1, 44100, 377, 0.2, 0.01, 0.01
To Pitch: 0.01, 75, 600
minimum = Get minimum: 0, 0, “hertz”, “parabolic”
appendInfoLine: "Minimum: ", minimum, " Hz"
maximum = Get maximum: 0, 0, “hertz”, “parabolic”
appendInfoLine: "Maximum: ", maximum, " Hz"
=>
Pitch extrema:
Minimum: 376.99629006909987 Hz
Maximum: 377.0418578707818 Hz

The following script builds a table with statistics about a pitch contour:

writeInfoLine: “Minimum”, tab$, “Maximum”
appendInfo: fixed$ (minimum, 3)
appendInfo: tab$
appendInfo: fixed$ (maximum, 3)
appendInfoLine: “”
=>
MinimumMaximum
376.996377.042

The little string tab$ is a tab character; it allows you to create table files that can be read by some spreadsheet programs. The little string newline$ is a newline character; it moves the following text to the next line.

You could combine the last four print statements into:

appendInfoLine: fixed$ (minimum, 3), tab$, fixed$ (maximum, 3)
=>
376.996377.042

which is the same as:

appendInfo: fixed$ (minimum, 3), tab$, fixed$ (maximum, 3), newline$
=>
376.996377.042

To clear the Info window, you can do

writeInfo: “”

or

clearinfo

Links to this page


© Paul Boersma 2022-12-02,2025