Lee Mac Posted January 23, 2011 Posted January 23, 2011 Had some fun with a recent sub, resulted in these two programs Autoloader This program will generate autoload expressions for all LISP files in a selected directory, proceeding to write such expressions to a text file output (from which the user may copy the contents to an ACADDOC.lsp or destination of their choice). GetSyntax A fun one - sparked from this thread, involving a question regarding how to determine the command to use to call a program when there is no indication in the code header and no loading messages indicating such information. This program will read a selected LISP file and print a report detailing the command syntax for all defined commands in the selected file. Both programs use my GetSyntax sub, which reads a supplied LISP file and returns a list of defined commands within the supplied file. Enjoy! Lee Quote
Lee Mac Posted January 25, 2011 Author Posted January 25, 2011 Updated Autoloader program code to account for bug in the AutoLISP autoload function. Quote
BlackBox Posted August 8, 2011 Posted August 8, 2011 Hi Lee, One thing I noticed when trying Autoloader recently, is that functions that have been commented out using ";|" and "|;" are also being added to the 'cmdlist' of the resultant autoload statement. Especially given that the characters used can be used for block, or in-line commenting, I'm not sure how much additional work it would be to account for this... I would presume there would be a vl-string-search test, then some sort of conditional parsing of the current line being read. Examples: (defun c:FOO2 () (prompt "\nThis is \"FOO2\"") (princ)) [color=seagreen];| (defun c:FOO1 () (prompt "\nThis is \"FOO1"\") (princ)) |; ;|(defun c:FOO () (prompt "\nThis is \"FOO"\") (princ)) |;[/color] ... Where the resultant autoload statement would be: (autoload "[color=red]<FilePath>[/color]/[color=red]<FileName>[/color].lsp" '("FOO2" "FOO1" "FOO")) Regardless, Autoloader saves me loads of time, and for that I say thank you! Quote
Lee Mac Posted August 8, 2011 Author Posted August 8, 2011 Good catch Renderman, thanks! The subfunction used by both programs described in this thread is my 'getsyntax' subfunction, which is currently quite simple. I think I would need to severely update this subfunction to account for the cases you have illustrated and other such situations involving commented defuns. Anyway, thanks for the heads up! Lee Quote
BlackBox Posted August 8, 2011 Posted August 8, 2011 Lee Mac said: Good catch Renderman, thanks! The subfunction used by both programs described in this thread is my 'getsyntax' subfunction, which is currently quite simple. I think I would need to severely update this subfunction to account for the cases you have illustrated and other such situations involving commented defuns. Anyway, thanks for the heads up! Lee You're very welcome! If I were more skilled, I'd have offered you something more than verbal-pseudo code for a solution. LoL Quote
BlackBox Posted August 10, 2011 Posted August 10, 2011 Lee, I feel silly for having to ask this, but I'm only now experimenting with Autoload & Autoloader respectively. Is there any way to 'Autoload' a sub-function which accepts arguments? Using your Dump Object samples: (defun LM:Dump (object) (vl-load-com) (if (setq object (cond ((eq 'ENAME (type object)) (vlax-ename->vla-object object) ) ((listp object) (cdr (assoc -1 object)) ) ((eq 'VLA-OBJECT (type object)) object ) ) ) (progn (vlax-dump-object object t) (textpage) ) ) (princ) ) (defun c:dump nil (LM:Dump (car (entsel)))) (defun c:dumpn nil (LM:Dump (car (nentsel)))) As this is merely a learning exercise (for me), can this LISP file (let's call it ObjectDump.lsp) be 'Autoloaded' if you were to call this from the command line? (LM:Dump (vlax-get-acad-object)) Autoloader produces this: (autoload "[color=red]<FilePath>[/color]/ObjectDump.lsp" '("DUMP" "DUMPN")) Or, is one relegated to explicitly LOAD-ing any LISP files which contain sub-functions in order for them to be available without the function (defun c: ...) version? Quote
Lee Mac Posted August 10, 2011 Author Posted August 10, 2011 AFAIK, you cannot include subfunction names in the autoload function command list, however, any subfunctions included in the same file as the command being loaded will also be loaded by autoload. For demand-loading subfunctions, you would have to create your own 'autoload' function, as demonstrated in this thread, among others. Lee Quote
BlackBox Posted August 10, 2011 Posted August 10, 2011 Thanks for the confirmation, Lee. Edit: Just going through the linky now, it'll take some time for me to digest - but - very cool stuff. Thanks for sharing. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.