If you use RK's example, you won't need to use EXIT. However, if you do use EXIT, you can use an error handler to catch it and then display nothing. I'll try to explain RK's example a bit more here (comments in red):
Code:
;;check to see which path to take
(if (test)
;;do what you need to here.
;;when it is finished, it will
;;exit the IF statement
(do this and then exit)
;;use PROGN to encapsulate more
;;functions into the IF statement
(progn
(do this and then continue)
(more functions)
(some more functions)
(some more functions)
(even more functions)
(even more functions)
(even more functions)
)
;;when you get past the IF statement
;;you can safely exit the program
;;using a PRINC for a 'silent' exit
(princ)
However, if you need to use the EXIT function, you can use an error handler like so (comments in red):
Code:
;;make sure to define *Error* as local
(defun c:myProg (/ *Error*)
;;redefine the global error handler within your routine
(defun *Error* (msg)
;;check for contents of msg
(cond
;;if msg is nil, do nothing
((not msg))
;;if msg is "quit / exit abort" (the content you want to trap from
;;the EXIT function, do nothing
;;NOTE: you may get this if the user cancels the routine as well
((equal (strcase msg t) "quit / exit abort"))
;;if msg is within this list, user may have canceled the function
((member (strcase msg t) '("console break" "function canceled"))
;;inform the user the routine was canceled
(princ "*Cancel*\n")
)
;;something else happened, print the error
((princ (strcat "\n; error: " msg "\n")))
)
;;'silent' exit
(princ)
);;end of *Error*
;;-------
;;start of main routine
;;-------
(if (test)
(progn
(your code here)
(exit)
)
(progn
(your alternate code here)
(more of your code here)
(more of your code here)
(more of your code here)
)
)
;;use the error handler for any cleanup,
;;including 'silent' exit
(*Error* nil)
)
I will note this, it would be preferable to use RK's suggestion along with the error handler. Using the EXIT function would be used more for an error condition. From the help:
If
exit is called, it returns the
error message quit/exit abort and returns to the AutoCAD Command prompt.
Emphasis added
If you want to use it in that regard, you can use the error handler method and do something like this code snippet (comments in red):
Code:
;;check for 'custom' error condition
(if (test-for-error)
(progn
;;if your custom error occurred, call the LOCAL *Error* handler,
;;your custom message will be displayed
(*Error* "Something happened that wasn't supposed to.")
;;then call EXIT, nothing should be displayed if the *Error*
;;function is defined as above ^
;;alternatively, you can have the "quit / exit abort" within the list and
;;allow the *Error* handler to issue a "Canceled" to the cmd prompt
(exit)
)
)
Anyway, there's three different ideas for you to choose from
I hope that at least one of them covers what you need.