Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Section - [11] S::STARTUP, My LISPs aren't loaded at startup anymore

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Forum ]


Top Document: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Previous Document: [10] Iteration with MAPCAR,...
Next Document: [12] How to Autoload my programs?
See reader questions & answers on this topic! - Help others by sharing your knowledge
  LISP files can be loaded at the startup using LOAD in ACAD.LSP.
  Some LISPs, required with a menu to work, should be loaded from
  the corresponding <menu>.MNL file. The <menu>.MNL file - if different -
  should load ACAD.MNL

  LISP functions calling commands at the startup should be defined in
  S::STARTUP of ACAD.LSP. This function is called at the startup
  after the initialization automatically. Otherwise you'll get the
  "Command list interruption (6 . 2)" errors.
  Note: (command) may be safely called from within MNL files. 
  (S::STARTUP) is mainly used to check for partial menus now.

  If the file name was provided without an extension the LOAD function
  assumes .LSP. If - without a path prefix, the usual AutoCAD library path
  is used, which is
    1) The current directory
    2) The directory containing the current drawing file
    3) The directories defined in the ACAD environment variable
       (setup in the Preferences box, SUPPORT paths)
    4) The acad.exe directory
  If your program isn't loaded anymore automatically, check your AutoCAD
  library path settings.

  With ACADLC (of ACOMP) and the domestic release of AutoCAD R12 ACAD.LSP
  is not loaded automatically. Therefore you must append (load "ACAD" -1)
  to your ACAD.MNL.

  Sample ACAD.LSP:
  ;;;ACAD.LSP
  ;;; Fred the Beaver, 12/12/94
  (load "init" -1)                ; this loads some tools of mine
  (defun S::STARTUP ()
    (load "new-end" -1)           ; this redefines the END command
  )

  The -1 argument provides LOAD from interrupting the startup process, if
  any LOAD failure (causing an AutoLISP error). If a failure at the
  load-time occurs, -1 is returned, but the evaluation does not stop.
  -1 can be any expression as well.

  Sample code to enhance S::STARTUP in your code. With Visual LISP
  compiled code this will not work, it must be defined with DEFUN-Q
  instead. Functions are generally no lists anymore! Better than to
  use DEFUN-Q for S::STARTUP is to check for known hooks, a list of
  user-defined functions which are inserted and evaluated at run-time.

  (defun MY::STARTUP ()         ;your startup code goes here
    ;..
    (princ))

  (setq S::STARTUP
    (if (and S::STARTUP (listp S::STARTUP))     ;already defined in
                                                ; ACAD.LSP or elsewhere
      (append S::STARTUP (cdr MY::STARTUP))     ;append your code
      MY:STARTUP))                              ;just your code

  or a simple one:

  (if (and S::STARTUP (listp S::STARTUP))       ;usually called consp
     (setq S::STARTUP (append S::STARTUP (list func '(princ))))
     (setq S::STARTUP (list nil func '(princ))))

+ Vladimir Nesterovsky:
  The main difference now in A2K+ versions is that functions defined 
  with DEFUN are now a new datatype, USUBRs, and not lists as before. 
  But when the function is defined with DEFUN-Q, it is a list still, 
  like in previous versions. 

  Here's the utility function to use that works in both cases: 

  (defun plug-into-startup (funcname) ;by VladimirNesterovsky
    "to be called with quoted function name"
    (eval (list
      'defun 's::startup ()
      (if s::startup (list (list 'quote s::startup)))
      (list funcname))))

  So if you have all your startup code packed into one routine 

  (defun my-startup ()
    (alert "My Startup"))

  You make it work with the call 

  (plug-into-startup 'my-startup)

  Inside your code that is executed on startup, e.g. acaddoc.lsp 
  or whatever.

  See also  "[12] How to Autoload my programs?"

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Previous Document: [10] Iteration with MAPCAR,...
Next Document: [12] How to Autoload my programs?

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
rurban@xarch.tu-graz.ac.at (Reini Urban)





Last Update March 27 2014 @ 02:11 PM