Given that new versions of Audacity support many new features for Nyquist plug-ins that are not supported by old versions of Audacity, it can be useful to include a test in new public plug-ins to ensure that the version of Audacity is recent enough to run the plug-in correctly.
As of Audacity 2.1.0, there is a property list for the variable AUDACITY, which includes the Audacity version. See: https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#.2AAUDACITY.2A
Here’s a code snippet for testing that the script is running on a version of Audacity that is the same as, or later than the required version. In this example, the required version is 2.1.1
(defun versioncheck(minversion)
;; 'minversion' is the required minimum version as
;; a list of three integers.
;; Return true if current version >= 'minversion'
(if (or (not (listp minversion))
(/= (length minversion) 3))
nil
(prog ((v (get '*audacity* 'version)))
(when (not v)
(return nil))
(mapc (lambda (x)
(when (not (integerp x))
(error "list of 3 integers required")))
minversion)
(mapc (lambda (required actual)
(when (> required actual)
(return nil))
(when (< required actual)
(return t)))
minversion v)
(return t))))
;Test it
(if (versioncheck (list 2 1 1))
(print "Pass")
(print "Fail"))