Author Topic: Unloading a VBA Project  (Read 4518 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: Unloading a VBA Project
« Reply #15 on: January 28, 2008, 09:30:57 AM »

Sure Matt
I'd be interested to see it as well.

Thanks!
Mark

Guest

  • Guest
Re: Unloading a VBA Project
« Reply #16 on: February 04, 2008, 08:33:57 AM »

Sure Matt
I'd be interested to see it as well.

Thanks!
Mark

Better late than never!  I didn't include everything, but I think you'll be able to figure out what's going on.


Here's what the MENU.FIL file looks like.

Code: [Select]
[MENU]
VERSION=84
[SLIDE]
VERSION=16
[ACAD]
VERSION=33
[SDSKDFM]
VERSION=2
[DVBS]
VERSION=36
[DETAILS]
VERSION=14

And here's what the update file (UPDATE.LSP) looks like.

Code: [Select]
;;;=================================================================================================
;;; Function:    LOADDOSLIB
;;;
;;; Description: Loads DosLib
;;;=================================================================================================
(defun LoadDosLib ()
   (if (= (substr (getvar "acadver") 1 2) "17")
      (if (null dos_about)(arxload (strcat LSPDir "doslib17")))
      (if (null dos_about)(arxload (strcat LSPDir "doslib2004")))
   )
   (princ)
)


;;;=================================================================================================
;;; Function:    UNLOADDOSLIB
;;;
;;; Description: Unloads DosLib
;;;=================================================================================================
(defun UnloadDosLib ()
   (if (= (substr (getvar "acadver") 1 2) "17")
      (if (not (null dos_about)) (command "arx" "unload" "doslib17"))
      (if (not (null dos_about)) (command "arx" "unload" "doslib2004"))
   )
   (princ)
)


;;;=================================================================================================
;;; Function:    UPD8
;;;
;;; Description: Update the menu file
;;;=================================================================================================
(defun Upd8 (menuFile / strVersion)
   (vl-load-com)
   (setvar "cmdecho" 0)
   (setvar "menuecho" 0)
   (if (findfile (strcat CAD_Dir menuFile ".fil"))
      (progn
         ; If the MENU.FIL exists...
         (LoadDosLib)
         (CheckMenu)
         (CheckSlideFile)
         (setq strVersion (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-product-key)) "ProductName"))
         (cond
            ((= strVersion CAD_ACAD_LDT)
               (CheckDFM)
            )
         )
         (CheckDvbs)
         (CheckDetails)
         (UnloadDosLib)
      )
      (progn
         (LoadDosLib)
         (CreateMenu)
         (dos_copy (strcat UpdDir menuFile ".fil") (strcat CAD_Dir menuFile ".fil"))
         (UnloadDosLib)
      )
   )
   (setq strVersion nil)
   (princ)
)


(defun CheckDVBs ( / mFile1 mFile2 lstFiles strFName)
   (setq mFile1 (dos_getini "DVBS" "VERSION" (strcat CAD_Dir menuFile ".fil")))
   (setq mFile2 (dos_getini "DVBS" "VERSION" (strcat UPDDir menuFile ".fil")))
   (if (/= mFile2 mFile1)
      (progn
         (dos_attrib (strcat CAD_Dir "*.*") 0)
         (setq lstFiles (vl-directory-files CAD_Dir "*.dvb" 1))
         (foreach strFName lstFiles
            (vl-file-delete (strcat CAD_Dir strFName))
         )
         (CopyDVBs)
         (dos_setini "DVBS" "VERSION" mFile2 (strcat CAD_Dir menuFile ".fil"))
      )
   )
)


(defun CopyDVBs ( / )
   (dos_copy (strcat DVBDir "ABSMatch.dvb")           (strcat CAD_Dir "ABSMatch.dvb"))
   (dos_copy (strcat DVBDir "Batch_Processor.dvb")    (strcat CAD_Dir "Batch_Processor.dvb"))
   (dos_copy (strcat DVBDir "Batch Binder.dvb")       (strcat CAD_Dir "Batch Binder.dvb"))
   (dos_copy (strcat DVBDir "Block To Device.dvb")    (strcat CAD_Dir "Block To Device.dvb"))
)

And here's how I start the update....

Code: [Select]
(load "update")(upd8 "menu")