home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 6.img / BONUS1.LIB / DDTYPE.LSP < prev    next >
Encoding:
Text File  |  1993-02-09  |  2.7 KB  |  77 lines

  1. ;---------------------------------------------------------------------------;
  2. ;
  3. ;   DDTYPE.LSP   ¬⌐Ñ╗ 1.0
  4. ;
  5. ;     ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  6. ;
  7. ;     Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  8. ;     ¡∞½h :
  9. ;
  10. ;     1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  11. ;     2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  12. ;
  13. ;     Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  14. ;     Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  15. ;
  16. ;
  17. ;   by Duff Kurland
  18. ;   4 Dec 1991
  19. ;
  20. ;---------------------------------------------------------------------------;
  21. ;
  22. ;  DESCRIPTION
  23. ;
  24. ;    Implements a DDTYPE command to list a specified ASCII text file in
  25. ;    a dialog box.  The file name is obtained via a get-file dialog.
  26. ;    Any file type (extension) is permitted; "doc" is the default.
  27. ;
  28. (defun ddtype_err (s)                 ; If an error (such as CTRL-C) occurs
  29.    (if (/= s "Function cancelled")
  30.       (princ (strcat "\n┐∙╗~: " s))
  31.    )
  32.    (if olderr (setq *error* olderr))  ; Restore old *error* handler
  33.    (princ)
  34. )
  35.  
  36. (defun C:DDTYPE (/ fn fd dcl_id line olderr)
  37.    (setq olderr  *error*              ; Save error routine
  38.          *error* ddtype_err           ; Substitute ours
  39.          fn      "~"                  ; Assume a ~
  40.          fd      nil                  ; Assume no file descriptor
  41.    )
  42.    (while (= "~" fn)
  43.      (if (= 1 (setq fn (getfiled "╣w│╞ªCÑ▄¬║└╔«╫" "" "doc" 4)))
  44.          (setq fn (getstring "\n┐ΘñJ╣w│╞ªCÑ▄¬║└╔«╫: "))
  45.      )
  46.    )
  47.    (if (and fn                        ; Got filename?
  48.             (setq fd (open fn "r"))   ; ...and can read the file?
  49.             (>= (setq dcl_id (load_dialog "ddtype.dcl")) 0)
  50.             (new_dialog "ddtype" dcl_id))  ; ...and dialog def'n is okay?
  51.       (progn
  52.          (set_tile "title" fn)        ; Place filename in dialog title area
  53.          (start_list "list_box")      ; Read file's contents into list box
  54.          (while (setq line (read-line fd))
  55.             (add_list line)
  56.          )
  57.          (end_list)
  58.          (setq fd (close fd))         ; Close the text file
  59.          (start_dialog)               ; Run the dialog
  60.          (unload_dialog dcl_id)       ; Unload the dialog
  61.       )
  62.       (progn                          ; Something went wrong
  63.          (if fd                       ; If file is okay, must be dialog error
  64.             (progn
  65.                (close fd)             ; Close the text file
  66.                (print "íu╣∩╕▄«╪ív┐∙╗~íC\n")
  67.             )
  68.             (if fn                    ; File not open, but might be CTRL-C
  69.                (princ (strcat "╡L¬k╢}▒╥íu" fn "ívÑH¿╤┼¬¿·íC\n"))
  70.             )
  71.          )
  72.       )
  73.    )
  74.    (setq *error* olderr)
  75.    (princ)
  76. )
  77.