Summary
This document shows how you can close a current project and open a predefined project by clicking on a Menu, Button, or Tool.
Procedure
- Copy the OpenProject and OpenProject2 scripts into new separate script windows of a new blank project.
Code:
'Script Name: OpenProject
'Modified from System Script Project.Open
theProject = av.GetProject
if (nil <> theProject) then
if (theProject.IsModified) then
if (av.Run("Project.CheckForEdits",nil).Not) then
return nil
end
res = MsgBox.SaveChanges("Do you want to save changes to "
+ theProject.GetName + "?", "ArcView", true)
if (nil = res) then return nil end
if (res) then
av.Run("Project.Save", nil)
if (theProject.IsModified)then return nil end
end
end
end
theFName = SELF.GetTag.AsFileName
if (nil <> theFName) then
if (nil <> theProject) then
theProject.Close
end
theProject = nil
av.ClearGlobals
av.DelayedRun("OpenProject2", theFName, 0)
end
Code:
'Script Name: OpenProject2
'Modified from System Script Project.OpenPart2
' self is the name of the project to open
av.PurgeObjects
av.ProcessAllInvals
Project.Open(self)
av.Run("Codepage.Install",nil)
theProj = av.GetProject
if (theProj <> nil) then
guiModified = av.Run("Project.UpdateApr",nil)
self.SetModified(guiModified)
end
- Rename the script window to match the name of the script.
A. Select Properties from the Script menu.
B. Type in a new name in the Name field.
C. Click OK.
- Attach the OpenProject script to a control on a GUI, for example a button on the View GUI.
A. Compile the script.
B. Switch to the Project window.
C. Select Customize from the Project menu.
D. On the Customize dialog box, click the Type dropdown arrow and click View.
E. Select Buttons under Category.
F. Click the New button.
G. Double-click the Click property in the Customize dialog box.
H. Type the name of the script in the Script Manager and click Select.
I. Close the Customize dialog box.
For more information, see "Customize dialog box" in ArcView Help.
- Set the tag of the new control to the full path and filename of the project to open.
A. Switch to the Project window
B. Select Customize from the Project menu
C. On the Customize dialog switch the Type dropdown to the GUI where the control is located
D. Switch the Category dropdown to the type of control you are setting
E. Select the control
F. Double-click the Tag property at the bottom of the Customize dialog
G. Enter the desired text and click OK
H. Close the Customize dialog box
- Make the project the default project.
A. Switch to the Project window
B. Select Customize from the Project Menu
C. Click Make Default on the Customize dialog box
D. Close the Customize dialog box
Note:
The Make Default button is not available if any extension are turned on. To activate this button turn off all extensions.
Note:
Make sure both scripts are compiled.
- Restart ArcView. The new control will be added automatically.