; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
; ³  Z W G I N S R T  v1.0   ³± 
; ³    Copyright (c) 1992    ³± 
; ³   by Kurtis J. Jones /   ³±
; ³      -Mate Software      ³±
; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ±
;  ±±±±±±±±±±±±±±±±±±±±±±±±±±±±
;
;
; DISCLAIMER OF WARRANTY:
; -----------------------
;
; THIS SOFTWARE AND MANUAL ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS OF PURPOSE.  THE USER OF THIS
; SOFTWARE AND MANUAL ASSUMES ALL RISKS.
;
;
; INSTRUCTIONS/USE:
; -----------------
;
; Unmodified copies of this program and the accompanying documentation may be
; made and distributed freely without charge.  Under no circumstances shall
; this program or the accompanying documentation be distributed as part of any
; for-profit venture, without expressed written permission from the author.
;
; This simple LISP program will allow you to insert drawing files as blocks
; that have been compressed using AUTO-MATE.  ZWGINSRT prompts you for the
; name of the .ZWG drawing file (do not include the extension) as well as the
; compression program to be used.  You must include the full path to the
; drawing file to be inserted unless it is located in the current DOS sub-
; directory.  The default compression program used by ZWGINSRT is PKUNZIP;
; however, you should specify the compression program (along with any 
; applicable command line switches) that was originally used in AUTO-MATE to
; compress the drawing file.
; 
; The following is a list of the more popular compression programs along with
; the required input for use with ZWGINSRT:
;
;      Compression Program                 Uncompress Command
;      -------------------                 ------------------
;         PKZIP by PKWARE, Inc.               PKUNZIP
;         PKARC by PKWARE, Inc.               PKXARC
;         PAK by NOGATE CONSULTING            PAK E
;         LHARC by Haruyasu Yoshizaki         LHARC E
;         ZOO by Rahul Dhesi                  ZOO E
;
; If you have any questions are comments about ZWGINSRT, I can be reached
; via THE SPECTRUM BBS, (501) 521-5639.
;
;------------------------------------------------------------------------------
; * Error trapping *
;------------------------------------------------------------------------------
;
(defun *ERROR* (ERR_MSG)
   (if (/= ERR_MSG "Function cancelled")
      (if (/= ERR_MSG "quit / exit abort")
         (prompt (strcat "\nE_R_R_O_R_!: " ERR_MSG "\n "))
      )
   )
   (zwgend)
)
;
;------------------------------------------------------------------------------
; * Parse filespec & path *
;------------------------------------------------------------------------------
;
(defun PARSE (FSPEC / PATH FNAME)
   (setq INC -1 LNGTH (strlen FSPEC) FNAME "")
   (while (and (/= LNGTH (1+ INC)) (not PATH))
      (if (member
             (setq CHAR
                (substr FSPEC (- LNGTH (setq INC (1+ INC))) 1)
             )
             '("/" "\\")
          );member
          (setq PATH (substr FSPEC 1 (- LNGTH INC)))
          (setq FNAME (strcat CHAR FNAME))
      )
   )
)
;
;------------------------------------------------------------------------------
; * End of program *
;------------------------------------------------------------------------------
;
(defun ZWGEND()
   (setvar "CMDECHO" ZWG_CE)
   (princ)
)
;
;------------------------------------------------------------------------------
; * This is the main program routine *
;------------------------------------------------------------------------------
;
(defun C:ZWGINSRT ()
   (prompt "\n ")
   (prompt "\nZ W G I N S R T  v1.0 -- Copyright (c) 1992 by Kurtis J. Jones / -Mate Software")
   (prompt "\n ")
;
; * Initialize system variables *
;
   (setq ZWG_CE (getvar "CMDECHO"))
   (setvar "CMDECHO" 0)
   
   (if (= COMPPROG_DEF nil)
      (setq COMPPROG_DEF "PKUNZIP")
   )
;
; * Get initial user input *
;
   (setq ZWGNAME (getstring "\nEnter .ZWG Block to INSERT (no extension): "))
   (setq COMP_PROG (getstring (strcat "\nEnter compression program <" COMPPROG_DEF ">: ")))
   (if (= COMP_PROG "")
      (setq COMP_PROG COMPPROG_DEF)
      (setq COMPPROG_DEF COMP_PROG)
   )

   (setq BLOCK_PATH (parse ZWGNAME))
   (if (= BLOCK_PATH ZWGNAME)
      (setq BLOCK_PATH "")
   )
;
; * Command to "UNZWG" the drawing file *
;
   (setq UNZWG (strcat COMP_PROG " " ZWGNAME ".ZWG " BLOCK_PATH))
;
; * Command to delete the "UNZWGed" .DWG file *
;
   (setq DELDWG (strcat "DEL " ZWGNAME ".DWG"))

   (command "SHELL" UNZWG)
   (graphscr)
   (setvar "CMDECHO" 1)
   (command "INSERT" ZWGNAME pause pause pause pause)
   (setvar "CMDECHO" 0)
   (command "SHELL" DELDWG)
   (graphscr)
   (zwgend)
)
;
;------------------------------------------------------------------------------
; * End of file *
;------------------------------------------------------------------------------
;
