About AutoLISP Errors When Loading Startup Files

If an AutoLISP error occurs while you are loading a startup file, the remainder of the file is ignored and is not loaded.

Files specified in a startup file that do not exist or that are not in the program's library paths generally causes an error. Therefore, you may want to use the onfailure argument with the load function. The following example uses the onfailure argument:

(princ (load "mydocapp1" "\nMYDOCAPP1.LSP file not loaded."))
(princ (load "build" "\nBUILD.LSP file not loaded."))
(princ (load "counter" "\nCOUNTER.LSP file not loaded."))
(princ)

If a call to the load function is successful, it returns the value of the last expression in the file (usually the name of the last defined function or a message regarding the use of the function). If the call fails, it returns the value of the onfailure argument. In the preceding example, the value returned by the load function is passed to the princ function, causing that value to be displayed at the command prompt.

For example, if an error occurs while the program loads the mydocapp1.lsp file, the princ function displays the following message and the program continues to load the two remaining files:

MYDOCAPP1.LSP file not loaded.

If you use the command function in an acad.lsp, acaddoc.lsp, or MNL file, it should be called only from within a defun statement. Use the S::STARTUP function to define commands that need to be issued immediately when you begin a drawing session.