Jump to content
Lee Mac

Autoloader & GetSyntax

Recommended Posts

Lee Mac

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

Share this post


Link to post
Share on other sites
asos2000

As usual awesome

Thanks

Share this post


Link to post
Share on other sites
Lee Mac

Thanks Hasan :)

Share this post


Link to post
Share on other sites
Lee Mac

Updated Autoloader program code to account for bug in the AutoLISP autoload function.

Share this post


Link to post
Share on other sites
BlackBox

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!

Share this post


Link to post
Share on other sites
Lee Mac

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! :beer:

 

Lee

Share this post


Link to post
Share on other sites
BlackBox
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! :beer:

 

Lee

 

You're very welcome! :thumbsup:

 

If I were more skilled, I'd have offered you something more than verbal-pseudo code for a solution. LoL

Share this post


Link to post
Share on other sites
BlackBox

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? :unsure:

Share this post


Link to post
Share on other sites
Lee Mac

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

Share this post


Link to post
Share on other sites
BlackBox

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.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...