An important feature of Nyquist plug-ins / scripts is that they return ONE result to Audacity. This is called “the return value”.
They can’t display a message and then continue.
If the return value is text (or a number), then Audacity will display that in a message window.
If the return value is a sound, then Audacity will replace the selected audio with the sound.
For full details, see: https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#Return_Values
Error checking for both center and bandwidth is superfluous. If center is NIL, then bandwidth will also be NIL, and vice versa.
(if (not octaves)
"Error.\nA spectral selection is required."
(setf dummy 1))
(if (not center)
"Error.\nNo center frequency selected."
(progn
(setf q (/ (sqrt (power 2.0 octaves))(- (power 2.0 octaves) 1)))
(bandpass2 *track* center q)))
If “octaves” is nil, then the first IF clause returns the string, “Error.\nA spectral selection is required.”. We’re not doing anything with that string (we’re not printing it) and there is no unhandled error, so the script continues to the next IF clause.
If “center” is NIL (which it will be when “octaves” is nil), then the second IF clause returns “Error.\nNo center frequency selected.”.
The PROGN block is not reached when “center” is nil, so the script has completed and the final return value (“Error.\nNo center frequency selected.”) is returned to Audacity.
Because the return value from the entire script is a string value, Audacity displays it in a message box.
You can just leave out the first IF clause because it will never do anything.
About PRINT:
The PRINT function prints to the debug stream and returns the string.
Consider this code:
(setf my-val (print "Hello World"))
(print "Goodbye")
my-val
Now run the code in the Nyquist Prompt and use the Debug button.
The return value from the script is “my-val”, which evaluates to “Hello World”, so Audacity displays “Hello World”.
Because we used the Debug button, Audacity will then open the Debug window, and we will see:
"Hello World"
"Goodbye"
“Hello World” was printed to the debug window by the PRINT statement in the first line of the script.
“Goodbye” was printed to the debug window by the PRINT statement in the second line of the script.
If you run the code with the “OK” button rather than the “Debug” button, then you only see the script’s return value and not the Debug window.
Hopefully this will make sense when you try it 