home *** CD-ROM | disk | FTP | other *** search
- ;---------------------------------------------------------------------------;
- ;
- ; DDTYPE.LSP ¬⌐Ñ╗ 1.0
- ;
- ; ¬⌐┼v (C) 1991-1992 Autodesk ñ╜Ñq
- ;
- ; Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
- ; ¡∞½h :
- ;
- ; 1) ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
- ; 2) ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
- ;
- ; Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
- ; Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
- ;
- ;
- ; by Duff Kurland
- ; 4 Dec 1991
- ;
- ;---------------------------------------------------------------------------;
- ;
- ; DESCRIPTION
- ;
- ; Implements a DDTYPE command to list a specified ASCII text file in
- ; a dialog box. The file name is obtained via a get-file dialog.
- ; Any file type (extension) is permitted; "doc" is the default.
- ;
- (defun ddtype_err (s) ; If an error (such as CTRL-C) occurs
- (if (/= s "Function cancelled")
- (princ (strcat "\n┐∙╗~: " s))
- )
- (if olderr (setq *error* olderr)) ; Restore old *error* handler
- (princ)
- )
-
- (defun C:DDTYPE (/ fn fd dcl_id line olderr)
- (setq olderr *error* ; Save error routine
- *error* ddtype_err ; Substitute ours
- fn "~" ; Assume a ~
- fd nil ; Assume no file descriptor
- )
- (while (= "~" fn)
- (if (= 1 (setq fn (getfiled "╣w│╞ªCÑ▄¬║└╔«╫" "" "doc" 4)))
- (setq fn (getstring "\n┐ΘñJ╣w│╞ªCÑ▄¬║└╔«╫: "))
- )
- )
- (if (and fn ; Got filename?
- (setq fd (open fn "r")) ; ...and can read the file?
- (>= (setq dcl_id (load_dialog "ddtype.dcl")) 0)
- (new_dialog "ddtype" dcl_id)) ; ...and dialog def'n is okay?
- (progn
- (set_tile "title" fn) ; Place filename in dialog title area
- (start_list "list_box") ; Read file's contents into list box
- (while (setq line (read-line fd))
- (add_list line)
- )
- (end_list)
- (setq fd (close fd)) ; Close the text file
- (start_dialog) ; Run the dialog
- (unload_dialog dcl_id) ; Unload the dialog
- )
- (progn ; Something went wrong
- (if fd ; If file is okay, must be dialog error
- (progn
- (close fd) ; Close the text file
- (print "íu╣∩╕▄«╪ív┐∙╗~íC\n")
- )
- (if fn ; File not open, but might be CTRL-C
- (princ (strcat "╡L¬k╢}▒╥íu" fn "ívÑH¿╤┼¬¿·íC\n"))
- )
- )
- )
- )
- (setq *error* olderr)
- (princ)
- )