Jump to content

Question: how many Defun commands in one lisp


CadJunky

Recommended Posts

Hey, guys. Maybe an easy one. How can I retrieve all of the defuns in my one master lisp file. I have one lisp file that has hundreds of individual command that reside within it.:)

Link to comment
Share on other sites

Welcome to CADTutor.

 

That can actually be a tough problem.

 

If:

  • The main file has not been loaded
  • There are no overwrite of the defun name when loading
  • The defun name is not a protected symbol
  • ALL variables the main file are localized
  • So on And So on

Then this could work :

[b][color=BLACK]([/color][/b]defun c:ldefun [b][color=FUCHSIA]([/color][/b]/ dl oldatoms newatoms[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq oldatoms [b][color=NAVY]([/color][/b]atoms-family 1[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]load [color=#2f4f4f]"[i][b]file_name[/b][/i]"[/color][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq newatoms [b][color=NAVY]([/color][/b]atoms-family 1[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]foreach a newatoms
   [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]member a oldatoms[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
       [b][color=MAROON]([/color][/b]setq dl [b][color=GREEN]([/color][/b]cons a dl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1 dl[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

Otherwise, if you are VERY consistent in your coding practices, you could read every line in the main file searching for the string defun and the extract the next word in that line as the function name.

 

-David

Link to comment
Share on other sites

Thanks, Lee Mac. Your routine worked exactly for what I was looking for. Much appreciated.

 

@David - Thanks for your reply. I appreciate it.

Link to comment
Share on other sites

Another read your lisp file line by line look for "(defun" then simply write that line to a text file. It will find all Command defuns, plain rtd and user AH:getval etc

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