By Adam Nagy
I have a command written in LISP that gets some information from the user through a dialog and now I would like to create a command line version of it that could also be called from a script. So I have MYCOMMAND and I would like to create -MYCOMMAND. How can I do it?
Solution
You just have to prefix your command name with a dash '-' and only use command line input methods like getstring, etc.
; the function itself
(defun myprint_func (mytext / )
(print mytext)
)
; the user interface version of the command
(defun c:myprint ( / mytext)
; use user interface (e.g. DCL dialog) to set mytext
; …
(myprint_func mytext)
(princ)
)
; the command line version of the command
(defun c:-myprint ( / mytext)
; use command line input functions to set mytext
(setq mytext (getstring "\nProvide text: "))
(myprint_func mytext)
(princ)
)

Leave a Reply