dreamer Posted December 10, 2005 Posted December 10, 2005 Hello Over the months, I have my own collection of LISP routines in one of my work folders; the routines are the contributions from this forum. When encounter a particular task and I remember there is a particular routine could achieve, I would load the application into the drawing by going into the said folder and pick the routine. The routines file-name are all in their simplest form. I am sure as my collection expands, I shall have problem finding the appropriate routine by memory. Appreciated if I could receive advice of a method to enable me to put description adjacent to each routine in order to make life easier? Thanks in advance. Quote
fixo Posted December 10, 2005 Posted December 10, 2005 Hi I do the following: Before every local function I insert three lines, which begin with symbols &&& In the first line the short description of action of function For example: &&& Draw MTEXT In the second line is an example of a call: &&& (mtext-add str pt ht alg) And the third line the brief description of arguments: &&& str-string, pt - 3d-point, ht - text height, alg - alignment And after local function I wrote string with this pattern only: &&& The separate program with dialog window displays all the line from function library which begin with the pattern "&&&", that return something like this : &&& Draw MTEXT &&& (mtext-add str pt ht alg) &&& str-string, pt - 3d-point, ht-text height, alg-alignment &&& (Here is the empty line after) &&& Next function... etc Maybe this is very stupid but this navigator is enough for my needs Thank you Fatty Quote
Vj Posted December 13, 2005 Posted December 13, 2005 Faced with the same problem I did the following: I renamed the lisp files by adding a description with the lisp defun also mentioned after an underscore for eg. Copy Align_CA.lsp instead of CA.lsp. Of course this means that you have to point to this new name when loading (or autoloading) the file. Needless to say that the contents of the original CA.lsp are unchanged. It still calls for CA to be wrtitten on the command line for you to use the lisp routine. Hope this helps.. Quote
hendie Posted December 13, 2005 Posted December 13, 2005 in my lisps I use the following: ;| the characters above (semi-colon + bar) denote commented lines anything placed between these sets of characters will be disregarded by the routine so I can write anything I like in here but I must finish with a bar + semi-colon |; or ; a semi-colon will comment out a single line Quote
dreamer Posted December 13, 2005 Author Posted December 13, 2005 Thanks to all the replies. I shall experiment every method. Dreamer Quote
Vj Posted December 15, 2005 Posted December 15, 2005 Fatty/Hendie: How does putting the description inside the routine help in identifying what a cryptically named XXX.lsp file from 'outside'? When I have to select a particluar lsp file, my browse command gets me to the folder with my files, but (at least) I cant see the descriptions written inside the file! Am I missing something here? Quote
hendie Posted December 15, 2005 Posted December 15, 2005 well, if you can't give your files meaningful names, then you have to think again about what you are doing. that aside you can easily do a search in explorer for files with certain text strings in them... or you could easily write another lisp that will loop through all lisps in a folder and return the filename with the header description. Simple, no ? Quote
CAB Posted December 16, 2005 Posted December 16, 2005 Something like this perhaps: ;Tip1775: LIB.LSP MANAGE ROUTINES ©2002, Roy Everitt ;;; Lib.lsp ;;; ;;; Permission to use, copy, modify, and distribute this software and its ;;; documentation for any purpose and without fee is hereby granted. ;;; ;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ;;; ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF ;;; MERCHANTABILITY ARE HEREBY DISCLAIMED. ;;; ;;; Copyright Quote
hendie Posted December 16, 2005 Posted December 16, 2005 see ! how easy is that then ? in fact, if I remember correctly there was one already wrapped up in the express tools a while back.. dunno if it's still there though ps.. Hi CAB ! Quote
CAB Posted December 16, 2005 Posted December 16, 2005 Hey hendie, I only go back to ACAD2000 & I didn't see it. But you're an ACAD old timer. PS: I seem to remember daron made one to read the first few line of the lisp file & write that to a text file or something like that. I looked not did not see it. If I find it I'll let you know. Quote
hendie Posted December 16, 2005 Posted December 16, 2005 if you check the express tools menu/help under command line only ~ you'll find a tool called LSPSURF I have 2004 here and it's still there ! it's not great and could certainly do with being re-written but.... time.. time... time Quote
CAB Posted December 16, 2005 Posted December 16, 2005 OK, I see it in ACAD2000 as well. Good find. Off to check it out. Thanks Quote
Geordie Posted December 18, 2005 Posted December 18, 2005 You can also have a look at this and use it to load your routines http://www.afralisp.co.za/zip/lispmanager.zip If you put a header into your routines it will read the first 10 lines Quote
CAB Posted December 19, 2005 Posted December 19, 2005 Stumbled over this one today in my archives. ;Finds all lisp files, sorts and writes first two lines to screen. ;Type SCANLSP2. ;****************************************************************************** ; "SCANLSP2" Public Domain, by Ron W. Lloyd 11/7/89 ; This is version 2.0 of SCANLISP, a lisp files manager. ; This routine writes the names of all .LSP files in a given directory to ; the screen with two lines of comments for each file. The comments are the ; first two lines of the file, assuming that most files are briefly ; commented there. If not, you can add your own as above. The files are ; alphabetized and you are given the opportunity to load, delete, or read ; any file or exit the routine. ; ; Note: Routine redefines *error*. You may wish to reset it later by typing ; (setq *error* #err) at your command prompt, if you abort this routine. ;****************************************************************************** ;redefine the error message to exit cleanly and tidy up files. (defun *error* (msg) (prompt "\e[m") (command "sh" "erase $ooz.$$l" "sh" "erase $gnk.$$l" ) (close hunt) (close sfile) (close file) (close lfile) (setq msg nil) (princ) ) ;***************************************************************************** ;Convert backslashes for path handling. (defun bs (path / inc wpath char) (setq inc 1 wpath "" ) (while (/= "" (setq char (substr path inc 1))) (setq wpath (strcat wpath (if (= "/" char) "\\" char ) ) ) (setq inc (1+ inc)) ) (if (and (/= wpath "") (/= (substr wpath (strlen wpath) 1) "\\")) (setq wpath (strcat wpath "\\")) ) wpath ) ;***************************************************************************** ;Load a lisp file. (defun ld (/ lname) (setq ftest nil) (while (not ftest) (setq lname (getstring "\nName of file to load: (.LSP assumed) ")) (setq lname (strcat pth lname ".LSP")) (setq ftest (findfile lname)) (if (= ftest nil) (prompt (strcat (strcase lname) " not found.")) ) ) (prompt (strcat "Loading " (strcase lname) " . . . . . .")) (load lname) ) ;****************************************************************************** ;Delete a lisp file. (Actually, renames to .BAK) (defun dlt (/ dname dlsp blsp fatal) (setq dname (getstring "\nName of file to delete: (.LSP assumed) ") dlsp (strcase (strcat pth dname ".LSP")) hunt (open dlsp "r") blsp (strcase (strcat pth dname ".BAK")) ) (if hunt (progn (initget "Y N") (setq fatal (getkword (strcat "\nAbout to erase " dlsp ". Are you sure? Yes/<No>: ") ) ) (if (= fatal "Y") (progn (setq renm (strcat "rename " dlsp " " dname ".bak")) (command "sh" renm) (prompt (strcat dlsp "has been re-named " blsp ". It can be erased from DOS." ) ) (prin1) ) ) (close hunt) ) (prompt (strcat dlsp " not found.")) ) (initget "Y N") (setq ans3 (getkword "\nContinue? <Yes>/No: ")) (if (or (null ans3) (= ans3 "Y")) (setq go t) (setq go nil) ) ) ;****************************************************************************** ;Read a lisp file one screen at a time. (defun seefile (/ fname sfile more i line) (setq sfile nil) (while (not sfile) (setq fname (getstring "\nName of file to see: (.LSP assumed) ")) (setq sfile (open (strcase (strcat pth fname ".LSP")) "r")) (if (not sfile) (prompt (strcat (strcase pth) (strcase fname) ".LSP not found.")) (progn (setq more t) (while more (setq i 23) (while (> i 0) (setq line (read-line sfile)) (if line (progn (prompt line) (terpri) ) (progn (setq i 1) (setq more nil) (prompt "\e[1m") (prompt "\n****End of file****") (prompt "\e[m") ) ) (setq i (- i 1)) ) (if more (progn (initget "M X") (prompt "\e[1m") (setq more (getkword "More/<eXit>: ")) (prompt "\e[m") (if (= more "X") (setq more nil) ) ) ) ) (close sfile) ) ) ) ) ;****************************************************************************** ;Main lisp file scan program. (defun c:scanlsp2 (/ pth dr1 file str cnt i chr2 name flnam lfile lst go ans ans2) (setvar "cmdecho" 0) (setq pth (getstring "\nEnter PATH to scan: <Current> ")) (setq pth (bs pth)) (if (null pth) (setq dr1 "dir *.lsp > $ooz.$$l") (setq dr1 (strcat "dir " pth "*.lsp > $ooz.$$l")) ) (command "sh" dr1) (command "sh" "sort < $ooz.$$l > $gnk.$$l") (setq file (open "$gnk.$$l" "r")) (repeat 2 (read-line file) ) (setq str (read-line file)) (setq cnt (atoi (substr str 7 6))) (if (/= cnt 0) (progn (textscr) (repeat 2 (read-line file) ) (setq go t) (while go (setq i 1) (while (and (< i (> cnt 0)) (setq chr2 t) (setq name (chr (read-char file))) (while (/= chr2 " ") (setq chr2 (chr (read-char file))) (if (/= chr2 " ") (setq name (strcat name chr2)) ) ) (setq flnam (strcat name ".LSP")) (prompt "\e[1m") (prompt flnam) (print) (prompt "\e[m") (setq lfile (open (strcat pth flnam) "r")) (setq lst (list (read-line lfile) (read-line lfile))) (foreach s lst (princ s) (terpri)) (close lfile) (setq cnt (- cnt 1)) (setq go (read-line file)) (setq i (+ i 1)) ) ;while index less than 9 (if (> cnt 0) (progn (setq go nil) (initget "R M L X D") (prompt "\e[1m") (setq ans (getkword " Read file/Load/Delete/eXit/<More>: " ) ) (prompt "\e[m") (if (null ans) (setq go t) ) (if (= ans "R") (progn (seefile) (initget "C X") (prompt "\e[1m") (setq ans4 (getkword "\n eXit/<Continue scan>: " ) ) (prompt "\e[m") (if (null ans4) (setq ans4 "C") ) (if (= ans4 "C") (setq go t) ) ) ) (if (= ans "M") (setq go t) ) (if (= ans "L") (ld) ) (if (= ans "D") (dlt) ) ) ;progn (progn (setq go nil) (initget "R L X D") (prompt "\e[1m") (setq ans2 (getkword "\n(End of LISP directory.) Read file/Load/Delete/<eXit>: " ) ) (prompt "\e[m") (if (= ans2 "L") (ld) ) (if (= ans2 "D") (dlt) ) (if (= ans2 "R") (seefile) ) ) ) ) ;while go ) ;progn (prompt (strcat "\nNo LISP files found in " (strcase pth))) ) ;if count not 0 (command "sh" "erase $ooz.$$l" "sh" "erase $gnk.$$l" ) (close file) (setq *error* #err) (princ) ) Quote
autolisp Posted July 13, 2010 Posted July 13, 2010 Stumbled over this one today in my archives. ;Finds all lisp files, sorts and writes first two lines to screen. ;Type SCANLSP2. ;****************************************************************************** ; "SCANLSP2" Public Domain, by Ron W. Lloyd 11/7/89 ; This is version 2.0 of SCANLISP, a lisp files manager. ; This routine writes the names of all .LSP files in a given directory to ; the screen with two lines of comments for each file. The comments are the ; first two lines of the file, assuming that most files are briefly ; commented there. If not, you can add your own as above. The files are ; alphabetized and you are given the opportunity to load, delete, or read ; any file or exit the routine. ; ; Note: Routine redefines *error*. You may wish to reset it later by typing ; (setq *error* #err) at your command prompt, if you abort this routine. ;****************************************************************************** ;redefine the error message to exit cleanly and tidy up files. (defun *error* (msg) (prompt "\e[m") (command "sh" "erase $ooz.$$l" "sh" "erase $gnk.$$l" ) (close hunt) (close sfile) (close file) (close lfile) (setq msg nil) (princ) ) ;***************************************************************************** ;Convert backslashes for path handling. (defun bs (path / inc wpath char) (setq inc 1 wpath "" ) (while (/= "" (setq char (substr path inc 1))) (setq wpath (strcat wpath (if (= "/" char) "\\" char ) ) ) (setq inc (1+ inc)) ) (if (and (/= wpath "") (/= (substr wpath (strlen wpath) 1) "\\")) (setq wpath (strcat wpath "\\")) ) wpath ) ;***************************************************************************** ;Load a lisp file. (defun ld (/ lname) (setq ftest nil) (while (not ftest) (setq lname (getstring "\nName of file to load: (.LSP assumed) ")) (setq lname (strcat pth lname ".LSP")) (setq ftest (findfile lname)) (if (= ftest nil) (prompt (strcat (strcase lname) " not found.")) ) ) (prompt (strcat "Loading " (strcase lname) " . . . . . .")) (load lname) ) ;****************************************************************************** ;Delete a lisp file. (Actually, renames to .BAK) (defun dlt (/ dname dlsp blsp fatal) (setq dname (getstring "\nName of file to delete: (.LSP assumed) ") dlsp (strcase (strcat pth dname ".LSP")) hunt (open dlsp "r") blsp (strcase (strcat pth dname ".BAK")) ) (if hunt (progn (initget "Y N") (setq fatal (getkword (strcat "\nAbout to erase " dlsp ". Are you sure? Yes/<No>: ") ) ) (if (= fatal "Y") (progn (setq renm (strcat "rename " dlsp " " dname ".bak")) (command "sh" renm) (prompt (strcat dlsp "has been re-named " blsp ". It can be erased from DOS." ) ) (prin1) ) ) (close hunt) ) (prompt (strcat dlsp " not found.")) ) (initget "Y N") (setq ans3 (getkword "\nContinue? <Yes>/No: ")) (if (or (null ans3) (= ans3 "Y")) (setq go t) (setq go nil) ) ) ;****************************************************************************** ;Read a lisp file one screen at a time. (defun seefile (/ fname sfile more i line) (setq sfile nil) (while (not sfile) (setq fname (getstring "\nName of file to see: (.LSP assumed) ")) (setq sfile (open (strcase (strcat pth fname ".LSP")) "r")) (if (not sfile) (prompt (strcat (strcase pth) (strcase fname) ".LSP not found.")) (progn (setq more t) (while more (setq i 23) (while (> i 0) (setq line (read-line sfile)) (if line (progn (prompt line) (terpri) ) (progn (setq i 1) (setq more nil) (prompt "\e[1m") (prompt "\n****End of file****") (prompt "\e[m") ) ) (setq i (- i 1)) ) (if more (progn (initget "M X") (prompt "\e[1m") (setq more (getkword "More/<eXit>: ")) (prompt "\e[m") (if (= more "X") (setq more nil) ) ) ) ) (close sfile) ) ) ) ) ;****************************************************************************** ;Main lisp file scan program. (defun c:scanlsp2 (/ pth dr1 file str cnt i chr2 name flnam lfile lst go ans ans2) (setvar "cmdecho" 0) (setq pth (getstring "\nEnter PATH to scan: <Current> ")) (setq pth (bs pth)) (if (null pth) (setq dr1 "dir *.lsp > $ooz.$$l") (setq dr1 (strcat "dir " pth "*.lsp > $ooz.$$l")) ) (command "sh" dr1) (command "sh" "sort < $ooz.$$l > $gnk.$$l") (setq file (open "$gnk.$$l" "r")) (repeat 2 (read-line file) ) (setq str (read-line file)) (setq cnt (atoi (substr str 7 6))) (if (/= cnt 0) (progn (textscr) (repeat 2 (read-line file) ) (setq go t) (while go (setq i 1) (while (and (< i (> cnt 0)) (setq chr2 t) (setq name (chr (read-char file))) (while (/= chr2 " ") (setq chr2 (chr (read-char file))) (if (/= chr2 " ") (setq name (strcat name chr2)) ) ) (setq flnam (strcat name ".LSP")) (prompt "\e[1m") (prompt flnam) (print) (prompt "\e[m") (setq lfile (open (strcat pth flnam) "r")) (setq lst (list (read-line lfile) (read-line lfile))) (foreach s lst (princ s) (terpri)) (close lfile) (setq cnt (- cnt 1)) (setq go (read-line file)) (setq i (+ i 1)) ) ;while index less than 9 (if (> cnt 0) (progn (setq go nil) (initget "R M L X D") (prompt "\e[1m") (setq ans (getkword " Read file/Load/Delete/eXit/<More>: " ) ) (prompt "\e[m") (if (null ans) (setq go t) ) (if (= ans "R") (progn (seefile) (initget "C X") (prompt "\e[1m") (setq ans4 (getkword "\n eXit/<Continue scan>: " ) ) (prompt "\e[m") (if (null ans4) (setq ans4 "C") ) (if (= ans4 "C") (setq go t) ) ) ) (if (= ans "M") (setq go t) ) (if (= ans "L") (ld) ) (if (= ans "D") (dlt) ) ) ;progn (progn (setq go nil) (initget "R L X D") (prompt "\e[1m") (setq ans2 (getkword "\n(End of LISP directory.) Read file/Load/Delete/<eXit>: " ) ) (prompt "\e[m") (if (= ans2 "L") (ld) ) (if (= ans2 "D") (dlt) ) (if (= ans2 "R") (seefile) ) ) ) ) ;while go ) ;progn (prompt (strcat "\nNo LISP files found in " (strcase pth))) ) ;if count not 0 (command "sh" "erase $ooz.$$l" "sh" "erase $gnk.$$l" ) (close file) (setq *error* #err) (princ) ) dear sir old thread code is not working 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.