Nyquist Property List Tutorial

From Audacity Wiki
Revision as of 22:28, 10 January 2019 by Stevethefiddle (talk | contribs) (Variables and Property Lists: begin Examples section)
Jump to: navigation, search

Variables and Property Lists

In general terms, a variable is a symbol which contains a value. The symbol can be any valid name, and its value may be changed (hence "variable"). In Nyquist, the value may be of any data type (for example, a number, a character, or even a sound) and may be changed from one data type to another. Unlike some programming languages, variables do not need to be declared before use - they can just be set, and then they exist.
In addition to the value of the variable, one or more "properties" may also be attached to the symbol. Each "property" has a name and a value. The properties are known collectively as the symbol's "property list".

Setting the value of a symbol "binds" the value to the symbol. A symbol that has no value (not even "nil") is said to be "unbound".

In addition to the value of a symbol, we can also attach properties. This is a way of associating a list of items, each with their own value, to a single variable. Each item is called a key or indicator, and we can give each key a value. This list of items is called a "property list" (or plist for short).

To get the value of a property, we use the GET command.

When getting the value of a property, we do NOT want to evaluate either the variable (symbol) or the key symbol, so we must "quote" both symbols to prevent evaluation.

  • Lisp syntax
(get 'varaiable-name 'property-name)
  • SAL syntax
set v = get(quote(varaiable-name ), quote(property-name))

Examples

The following examples may be run in the Nyquist Prompt.
For the full list of global property lists, refer to the Nyquist Plug-ins Reference.

*TRACK* Examples

As an example, if we have a variable called *TRACK* (which we do in version 4 plug-ins), and it has a property called NAME (which it does), then we can "get" the value of that property with:

 (GET '*TRACK* 'NAME) ; Lisp
 return get(quote(*TRACK*), quote(NAME)) ; SAL


Warning icon See also Property List Functions in the XLisp manual.