Jump to content

Autoloader & GetSyntax


Lee Mac

Recommended Posts

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

Link to comment
Share on other sites

  • 6 months later...

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...