TheSwamp

Code Red => VB(A) => Topic started by: ML on January 25, 2008, 04:11:14 PM

Title: Unloading a VBA Project
Post by: ML on January 25, 2008, 04:11:14 PM

I have a simple question:

After unloading a project (dvb) has anyone ever gotten the command line erroe
Execution error?

If so, does anyone know how to clear the error?

I would rather not see that error at the command line; doesn't look good :)

Thanks!
Mark
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 04:14:28 PM
post how your unloading, maybe
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 04:15:08 PM
if your unloading from within the sub, your essentially crashing out of vba to unload
Title: Re: Unloading a VBA Project
Post by: ML on January 25, 2008, 04:21:19 PM

Well

At the end of the sub,
I put
Code: [Select]
Application.UnloadDVB "K:\Full\Path\Projectname.dvb"

I tried addressing the error like this:
Code: [Select]
Application.UnloadDVB "K:\Full\Path\Projectname.dvb"

If Err.Description = "Execution error" Then
  Err.Clear
End If

End Sub
but I'm still getting the error
Title: Re: Unloading a VBA Project
Post by: ML on January 25, 2008, 04:25:30 PM

Yes

I realize that.
It is attempting to unload prior to reaching the end of the sub.
That is pretty silly.
Why would they have a method that does that?

Still if you put it right before the End Sub, all of the code executes just fine; I just don't want that error to appear on the command line.
That is why I am at least attempting to clear it.

We need an After Sub Executes event shewwww, it never ends

Mark
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 04:27:23 PM
I handle it by haveing a short LSP that loads, calls, and unloads the DVB
Code: [Select]
  (defun c:TepPSc ()
    (LOADER "pagesetup.dvb")
    (VL-VBARUN "pagesetup.dvb!PSTepCSize")
    (command "vbaunload" "pagesetup.dvb")
  )
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 04:27:46 PM
Loader is a function to check to see if the DVB is already loaded
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 04:28:40 PM

Well

At the end of the sub,
I put
Code: [Select]
Application.UnloadDVB "K:\Full\Path\Projectname.dvb"

I tried addressing the error like this:
Code: [Select]
Application.UnloadDVB "K:\Full\Path\Projectname.dvb"

If Err.Description = "Execution error" Then
  Err.Clear
End If

End Sub
but I'm still getting the error

thats because the eror handler never gets to run b/c you have unloaded it
Title: Re: Unloading a VBA Project
Post by: Guest on January 25, 2008, 04:31:14 PM
I don't unload my DVBs.  They used to reside on our network, but now each user has a copy on his/her computer.  Any time I make a change, the updated file is copied from the master location on the network and overwrites the one on the user's PC.  This way I can make changes to files and not have to worry about user's having a file open on the network, in which case, I wouldn't be able to make the change.

My two cents.
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 04:38:10 PM
ditto that, I have a batch routine that copies down the latest code each time they reboot
Title: Re: Unloading a VBA Project
Post by: ML on January 25, 2008, 04:55:11 PM

Sorry Guys
But I don't want to get into that
No offense, but to me that is a major pain in the a*s
Every time you make a minute change you have run a batch or a script to copy it to each user? sheww

There is no problem sharing a project but it MUST be unloaded after it is ran; that's all.

Usually I address it in the menu macro
Very simply:
After ^c^c-vbarun;etc. etc.^c^cvbaunload;PathandProject.dvb;

However, this module prompts the user to pick points and the vbaunload (in the menu macro) is not jiving well with that

CM,
In the menu macro, I have even used LISP (command "vbaunload" "projectname.dvb") but that isn't jiving well either

I appreciate the suggestion but
I don't want to run a LISP routine just to unload a dvb project.

Yes, you are totally right; unload is coming before the errorhandler too
I don't think we can say; on error err.clear?

Thanks guys!
Mark
Title: Re: Unloading a VBA Project
Post by: ML on January 25, 2008, 04:59:30 PM

Now

If you are sharing .pc3 files, that is a great idea
Tell the user that every night the pc3 files are getting overwritten so, do something with it if you don't want it overwritten.

See, in this case other people would be against sharing .pc3 files; I just prefer to share every possible thing, it makes management of everything a bit easier. Of course there are things that are inherently not able to be shared, but share what we can.

We even have a .pc3 file called custom.pc3 so that the set .pc3 files are not tampered with
Do you think people use it?
Of course not LOL
Well, a few :)

Hence the script

Mark
Title: Re: Unloading a VBA Project
Post by: David Hall on January 25, 2008, 05:02:05 PM
I use the lisp routine so that menu macros can call it, my typers can call it, etc
Title: Re: Unloading a VBA Project
Post by: Guest on January 28, 2008, 08:16:25 AM

Sorry Guys
But I don't want to get into that
No offense, but to me that is a major pain in the a*s
Every time you make a minute change you have run a batch or a script to copy it to each user? sheww

In my custom ACAD.lsp file (which is on the network and is run on every CADD station whenever a drawing is opened) I have a program that reads two files - one on the network and one on each user's HD - if ANYTHING is different in either of those files, files from the network are copied to the user's HD and those become the "latest and greatest" files.  The files that are being compared are INI-type files, so whenever I make a change to, let's say a DVB, I change the number in the DVBS section and *poof!*  The next time a user so much as even opens a drawing, the latest files are copied from the network to the HD WITHOUT the user even knowing!!  If you want, I can post some of the code so you can get a better idea of what's really going on.


Quote
[MENU]
VERSION=84
[SLIDE]
VERSION=16
[ACAD]
VERSION=33
[SDSKDFM]
VERSION=2
[DVBS]
VERSION=36

[DETAILS]
VERSION=14
Title: Re: Unloading a VBA Project
Post by: David Hall on January 28, 2008, 09:05:43 AM
i would be interested in seeing your comparison logic, or does it just use literal string comparison?
Title: Re: Unloading a VBA Project
Post by: ML on January 28, 2008, 09:30:57 AM

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

Thanks!
Mark
Title: Re: Unloading a VBA Project
Post by: Guest 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")