Removing Bombs from Extensions

If an extension that you created is causing ArcView projects to bomb on loading, you may need to remove some troublesome objects when making it. The following buried jewel is taken from DIALOG.PDF, which is included with the "Dialog Designer" extension. To download the extension, click HERE.)

Do your dialogs or other objects in your extension use object tags?

You should avoid setting object tags on objects in your source project as they may get written out to the extension. For example, if a script in your source project sets an object tag and you test that script, ArcView will create the object tag. If that object tag is attached to an object that gets incorporated into your extension (e.g., a dialog or menu item), it can cause problems in projects that load your extension. To avoid this problem, you should remove all object tags from your extension before you distribute it. Add the following lines of code to the end of your extension's Make script after the Commit statement.


RFileName = FileName.Make("$USEREXT/myext.avx")
WFileName = FileName.Make("$USEREXT/myext.tmp")
RFile = LineFile.Make(RFileName,#FILE_PERM_READ)
WFile = LineFile.Make(WFileName,#File_PERM_WRITE)
while (RFile.IsAtEnd.Not)
   buf = RFile.ReadElt
   if (buf.Contains("ObjectTag:").not) then
File.Copy(WFilename, RFileName)
This modification opens the avx file as a LineFile, creates a temporary file, and writes every line except ObjectTag lines in the avx file to the temporary file. Then the temporary file is copied to the avx file name.

Does your extension deliver a customized DocGUI?

If your extension delivers a customized DocGUI, it may contain extraneous information associated with the DocGUI. For instance, the Window menu of your DocGUI contains menu options to activate all documents that are currently open in the project. Also, the separator in this menu references an object that contains a list of the open windows. These menu options and the object tag are written to the extension with the DocGUI. This will cause problems in projects that load the extension.

If your customized DocGUI is a View or Layout, you may need to remove a few controls that the Dialog Designer installs into these DocGUIs. These controls are the "Show/Hide Control Tools" on the Windows menu and the "Design/Run Controls" on the Graphics menu. If your extension will not be dependent upon the Dialog Designer extension (dialog.avx), you should remove these menu options from these GUIs before you add them to your extension.

To remove the object tag and menu controls, add the following lines of code to your Make script where you add the View or Layout GUI.

'Get the customized View DocGUI from the project
viewGUI = av.getproject.FindGUI("View")
viewMenuBar = viewGUI.GetMenuBar

'Find separator that contains the object tag and set the object tag to nil
winUpdate = viewMenuBar.FindByScript("WindowMenuUpdate")

'Delete all the activate window menu options
cSet = winUpdate.GetControlSet
cList = cSet.GetControls
last = cList.Get(cList.Count - 1)
while (last <> winUpdate)
   last = cList.Get(cList.Count- 1)

'Find the controls that were added by Dialog Designer and remove them
showControlTools = viewMenuBar.FindByScript("GraphicControl.ShowHideTools")
designControls = viewMenuBar.FindByScript("GraphicControl.DesignRun")

'Then add your DocGUI to your extension

Back to AVTips