[Audacity-quality] File Separator in 'aud-do' on menus
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
|
From: Robert H. <aar...@gm...> - 2019-06-28 17:18:16
|
Hi
Mainly for Steve and James
I've recently tried to extract the first recent file from the menu via Nyquist.
The straight forward way of doing so seems to eliminate the (Windows)
file separator.
Therefore, I took another approach.
While this yields the correct result, the procedure is rather complicated.
Also: why do the recent files do not have an ID? The label can always
change but the ID would logically stay the same.
Searching for a menu entry by ID would thus yield the right result and
would not be prone to future menu rearrangements.
Here's the code for the Nyquist prompt (press debug):
;nyquist plug-in
;version 4
;type tool
;name "First Recent File"
;debugbutton true
;action "Searching for entry"
;author "Nemo Nemesis"
;release 2.3.2
;copyright "Public Domain"
; Note that we assume that this entry is always at the same place
; and the numbers are therefore hard-coded
; It would be better if this could be found by the ID, e.g. "recent-1"
;
(setf message (second (assoc 'label (nth 4 (aud-get-info "menus")))))
(format t "No file separator:~%~s" message)
(terpri)
; Note that the association list that we get
; from the following command is pretty useless
; as it returns the list '("whole menu as string" . t)'
; Hence the complicated extraction
;
(setf message (car (aud-do "GetInfo: Type=Menus Format=LISP")))
(setf out (make-string-input-stream message))
(setf latest-file
(dotimes (n 5 (format nil "~a" (read-line out)))
(read-line out)))
(setf start (1+ (string-search "\"" latest-file)))
(setf end (string-search "\"" latest-file :start start))
(format t "Correct separator, escaped:~%~s~%" (subseq latest-file start end))
(format t "or not escaped:~%~s" (subseq latest-file start end))
|