2011

Table Of Contents
S::STARTUP Function: Postinitialization Execution
You can define an S::STARTUP function to perform any needed setup
operations after the drawing is initialized.
The startup LISP files (acad.lsp and acaddoc.lsp) are all loaded into memory
before the drawing is completely initialized. Typically, this does not pose a
problem, unless you want to use the command function, which is not guaranteed
to work until after a drawing is initialized.
If the user-defined function S::STARTUP is included in an acad.lsp or acaddoc.lsp,
it is called when you enter a new drawing or open an existing drawing. Thus,
you can include a definition of S::STARTUP in the AutoLISP startup file to
perform any setup operations.
For example, if you want to override the standard HATCH command by adding
a message and then switching to the BHATCH command, use an acaddoc.lsp
file that contains the following:
(defun C:HATCH ( )
(alert "Using the BHATCH command!")
(princ "\nEnter OLDHATCH to get to real HATCH command.\n")
(command "BHATCH")
(princ)
)
(defun C:OLDHATCH ( )
(command ".HATCH")
(princ)
)
(defun-q S::STARTUP ( )
(command "undefine" "hatch")
(princ "\nRedefined HATCH to BHATCH!\n")
)
Before the drawing is initialized, new definitions for HATCH and OLDHATCH
are defined with the defun function. After the drawing is initialized, the
S::STARTUP function is called and the standard definition of HATCH is
undefined.
NOTE To be appended, the S::STARTUP function must have been defined with
the defun-q function rather than defun.
Because an S::STARTUP function can be defined in many places (an acad.lsp
or acaddoc.lsp or any other AutoLISP file loaded from any of these), it's possible
to overwrite a previously defined S::STARTUP function.
Automatically Load and Run AutoLISP Routines | 101