ext-template1This extension is intended only to illustrate how to create an extension.
exec play-piano-c4() exec play-pluck-c4()
This example uses an HTML file as the "root" of the extension. This is the preferred format when there is separate documentation and code.
This file is parsed by the Extension Manager of the NyquistIDE up to the line containing "End Metadata" (which in this file is inside an HTML comment).
The parser looks for:
<a name=play-piano-c4> before the definition of
play-piano-c4().
There is an optional additional extension file named nyquistwords.txt
that is parsed by NyquistIDE when it starts. The words in that file
are added to the IDE Completion List system so that users can see
these functions as completions. Users can also click on the
completions to find documentation.
The nyquistwords.txt for
this extension contains:
The meaning is as follows: Entries are pairs of lines. The first line of each pair gives the name to appear in the completion list. If the name is a function, follow the function name with a space, a list of parameters (possibly empty as in this case) and end with a close parenthesis ")". (There is no open parenthesis.) For example,play-piano-c4 ) ext-template1/ext-template1.html#play-piano-c4 play-pluck-c4 ) ext-template1/ext-template1.html#play-pluck-c4
describes theeq-highshelf signal hz gain [slope])
eq-highshelf function which takes 3
required positional and one optional parameters.
The second line of each pair is a URL, starting with the template
name. Notice that the URL includes the anchor that directs the browser
to exactly the definition of the function or variable. The NyquistIDE
will complete the URL based on the location of the local copies of
extensions (which will be in the lib directory.)
If you install this extension (ext-template1), and
start to type "play-pian..." you will see play-piano-c4()
in the Completion List.
play-piano-c4() [SAL]play-pluck-c4() [SAL]To enable autoloading, simply add the file
autoload.lsp to your files. Notice above that
autoload.lsp is one of the “Additional
Files.”
The autoload.txt file for this extension is:
This is a Lisp expression. The;; autoload the ext-template1 functions (autoload "c4-player.sal" 'play-piano-c4 'play-pluck-c4)
autoload function is
built-in, and the first parameter is the (double-quoted) name of the
file to load to load the extension. Note that there is no path (it
will be loaded relative to the extension directory.)
The remaining parameters are simply the names of (some of) the functions that are declared by this extension. Any function on this list will be defined as a stub that loads the extension when the stub is called the first time. Note the use of the single quote.
Notice that
If you autoload functions, your "Usage" instructions near the top of the file should probably not say anything about loading.
If you do not autoload functions, your "Usage" instructions
in this extension would probably mention the load
command, i.e.:
In this case, it is important to include the name of the extension in the path. Simply loadingload "ext-template1/c4-player.sal" exec play-piano-c4() exec play-pluck-c4()
"c4-player.sal" will not work
because ext-template1 is not on Nyquist's load
path. However, lib is on the load path, and
ext-template1 is in lib, so
"ext-template1/c4-player.sal" will work.