home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / R11SUPP.EXE / ALIAS.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1990-10-08  |  5.2 KB  |  180 lines

  1. ;;;   ALIAS.lsp
  2. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  3. ;;;  
  4. ;;;   Permission to use, copy, modify, and distribute this software and its
  5. ;;;   documentation for any purpose and without fee is hereby granted.  
  6. ;;;
  7. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
  8. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
  9. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  10. ;;; 
  11. ;;;   by Jan S. Yoder
  12. ;;;   29 January 1990
  13.  
  14. ;;;-------------------------------------------------------------------------;
  15. ;;; DESCRIPTION
  16. ;;;
  17. ;;; List all of the aliases found in the file "acad.pgp" if it can be found 
  18. ;;; in AutoCAD's search path, which means that they are available in AutoCAD.
  19. ;;; This routine lists them in a two column format, pausing after every 20 
  20. ;;; lines.
  21. ;;;
  22. ;;;-------------------------------------------------------------------------;
  23.  
  24. ;;;
  25. ;;; Look for an external definition file in AutoCAD's search path
  26. ;;; al_lfx == Alias_Look_For_Xfile
  27. ;;;
  28. (defun al_lfx (f_name r_or_w /)
  29.   ;; Look for f_name in AutoCAD's search paths.
  30.   (if (= r_or_w "w")
  31.     (if (setq temp (open f_name r_or_w))
  32.       temp                            ; Return file descriptor
  33.       (progn
  34.         (princ (strcat "\n\tCouldn't open " f_name " for writing. "))
  35.         (exit)
  36.       )
  37.     )
  38.     (if (setq lfile (findfile f_name))
  39.       (if (setq temp (open lfile r_or_w))
  40.         temp                          ; Return file descriptor
  41.         (progn
  42.           (princ (strcat "\n\tCouldn't open " f_name " for reading. "))
  43.           (exit)
  44.         )
  45.       )
  46.       nil                             ; or nil
  47.     )
  48.   )
  49. )
  50. ;;;
  51. ;;; Print the alias in a two column format, pausing after twenty lines.
  52. ;;;
  53. (defun al_pr1 (/ j al_str c_str tmpstr )
  54.   (setq j      0
  55.         al_str "" 
  56.         c_str  ""
  57.   )
  58.   (while (/= (setq tmpstr (substr line (setq j (1+ j)) 1)) ",")
  59.     (if (/= tmpstr " ")
  60.       (setq al_str (strcat al_str tmpstr))
  61.     )
  62.   )
  63.   (while (and (/= (setq tmpstr (substr line (setq j (1+ j)) 1)) "")
  64.               (/= tmpstr ";") 
  65.               (/= tmpstr ",")
  66.               (/= tmpstr "\n")
  67.          )
  68.     (if (and (/= tmpstr " ") (/= tmpstr "*") (/= tmpstr "\t"))
  69.       (setq c_str (strcat c_str tmpstr))
  70.     )
  71.   )
  72.   (if (= (strlen c_str) 0) (setq c_str "<Null>"))
  73.   (if (< (strlen al_str) 12) 
  74.     (progn
  75.       (repeat (- 12 (strlen al_str)) (setq al_str (strcat al_str  " ")))
  76.     )
  77.   )
  78.   (if (< (strlen c_str) 10) 
  79.     (repeat (- 10 (strlen c_str)) (setq c_str (strcat c_str  " ")))
  80.     (setq first T)
  81.   )
  82.   (if first 
  83.     (princ (strcat "\n    " al_str "= " c_str ))
  84.     (princ (strcat "\t\t    " al_str "= " c_str ))
  85.   )
  86.   (if (and first (< (strlen c_str) 11))
  87.     (setq lineno (1+ lineno)
  88.            first nil)
  89.     (setq first T)
  90.   )
  91.   (if (and (= lineno 20) first)
  92.     (progn
  93.       (princ "\n\n\t<More> ")
  94.       (grread)
  95.       (terpri)
  96.       (setq lineno 0)
  97.     )
  98.   )
  99. )
  100. ;;;
  101. ;;; Main function
  102. ;;;
  103. (defun c:alias (/ al_err al_oe s al_oce aliasi lineno first line lfile)
  104.  
  105.   (setq al_ver "1.00a")               ; Reset this local if you make a change.
  106.   ;;
  107.   ;; Internal error handler defined locally
  108.   ;;
  109.   (defun al_err (s)                   ; If an error (such as CTRL-C) occurs
  110.                                       ; while this command is active...
  111.     (if (/= s "Function cancelled")
  112.       (princ (strcat "\nError: " s))
  113.     )
  114.     (if al_oe                         ; If an old error routine exists
  115.       (setq *error* al_oe)            ; then, reset it 
  116.     )
  117.     (setq aliasi (close aliasi))
  118.     (setvar "cmdecho" al_oce)         ; Reset command echoing on error
  119.     (princ)
  120.   )
  121.   ;;
  122.   ;; Body of alias function
  123.   ;;
  124.   (if *error*                         ; Set our new error handler
  125.     (setq al_oe *error* *error* al_err) 
  126.     (setq *error* al_err) 
  127.   )
  128.  
  129.   ;;  
  130.   ;; Set command echoing off.
  131.   ;;
  132.   (setq al_oce (getvar "cmdecho"))
  133.   (setvar "cmdecho" 0)
  134.   ;;
  135.   ;; The default file name is "acad.pgp".
  136.   ;; Look for it in AutoCAD's search paths.
  137.   ;;
  138.  
  139.   (setq aliasi (al_lfx "acad.pgp" "r"))
  140.  
  141.   (if aliasi
  142.     (progn
  143.       (setq lineno 0
  144.             first T
  145.       )
  146.       (if textpage (textpage) (textscr))    ; For Release 10
  147.       (princ (strcat 
  148.         "\n    Alias  Version " al_ver ", (c) 1990 by Autodesk, Inc. "))
  149.       (princ (strcat 
  150.         "\n    This is a list of the aliases and external commands found in"
  151.         "\n    " 
  152.                      lfile ". \n"))
  153.       (while (setq line (read-line aliasi))
  154.         ;; Check each line for leading semi-colon
  155.         (if (and (/= (substr line 1 1) ";")     ; Leading semi-colon?
  156.                  (/= (substr line 1 1) "")      ; Blank line?
  157.                  (/= (substr line 1 1) "\n"))   ; Carriage return?
  158.           
  159.           (al_pr1)
  160.         )
  161.       )
  162.       (princ "\n")
  163.       (princ "\nPress any key to return to your drawing.")
  164.       (grread)
  165.       (princ "\r                                          ")
  166.       (graphscr)
  167.     )
  168.     ;; else
  169.     (progn
  170.       (princ "\nCouldn't find or read the file \"acad.pgp\". ")
  171.     )
  172.   )
  173.   (setq aliasi (close aliasi))
  174.   (if al_oce (setvar "cmdecho" al_oce))
  175.   (princ)
  176. )
  177.  
  178. (princ "\n\tC:ALIAS loaded.  Start command with ALIAS.")
  179. (princ)
  180.