Creating new commands to select tracks

Hi, I would like to select all tracks starting from the focused track up to top or down to bottom. Is there a way to do it maybe with Nyquist? I’ll really appreciate your help,
Thanks,
Juan Carlos

To extend a selection from the current (focussed) track to the first track, you could do something like this in Nyquist:

(defun getfocus ()
  (let ((count 1)
        (info (aud-get-info "tracks"))
        hasfocus)
    (dolist (tr info nil)
      (setf hasfocus (assoc 'focused tr))
      (when (and hasfocus (= (second hasfocus) 1))
        (return count))
      (incf count))))

(let ((f-track (getfocus)))
  (if f-track
      (aud-do-command "SelectTracks" :track 0 :trackcount f-track)
      "Track focus not found"))

Here it is as a plug-in:
select-above.ny (579 Bytes)
To select down, you will need something like this:

(defun getfocus ()
  (let ((count 1)
        (info (aud-get-info "tracks"))
        hasfocus)
    (dolist (tr info nil)
      (setf hasfocus (assoc 'focused tr))
      (when (and hasfocus (= (second hasfocus) 1))
        (return count))
      (incf count))))

(let ((f-track (1- (getfocus)))
      (all (get '*project* 'tracks)))
  (if f-track
      (aud-do-command "SelectTracks" :track f-track :trackcount (- all f-track))
      "Track focus not found"))

Thank you very much for your kind answer,
Juan Carlos