Application initialization
You use the methods described in this section for the following tasks:
Initialize class variables when an application is loaded
Remove unwanted instances from the image when an application is unloaded
Add or remove entries from the system menu when applications are loaded or unloaded
You can define the following class methods on the application's class:
addToSystemMenu
Add this method to any application that adds itself to the Tools menu. This method is sent each time the system menu is recomputed (by using System updateTranscriptMenus) after an application is loaded.
Applications that modify items in the menu should also implement the methods loaded and removing that add or remove the modified menu items to ensure that the menu is correct whenever the application is loaded or unloaded. For example, the application EtDevelopment implements the method addToSystemMenu as a public class method. This method ensures that the Browse Class, Browse Hierarchy, and other menu items are added to the Tools menu.
failedRemove
Applications that use the method removing must implement the method failedRemove to counteract anything done in the removing method. The method failedRemove is sent if an error occurs when unloading the application from an image. Some errors that can occur when unloading an application are:
Attempting to unload a class, but one or more of its subclasses are left in your image
Attempting to unload a class that has instances
Since the state of an application can be inconsistent if an application fails to unload all of its classes, the default implementation of this method, which is inherited by all applications, is to mark the application as a scratch edition.
loaded
Applications that execute code each time they are loaded (for example, to initialize classes or variables, or to re-evaluate the Tools menu) must implement the method loaded. It is sent to an application after it has been loaded or reloaded.
Since this method also runs when applications are reloaded, you should leave variables that have reasonable values alone instead of reinitializing them. To define any global or shared variables prior to loading, see the description above of the method toBeLoadedCode:.
removing
Any application can add this method to eliminate, prior to unloading the application, specific instances of its classes contained in class, shared, or global variables. This method also removes any entries added to the system menu. If an error occurs during unloading, the method failedRemove is sent to the application to counteract anything done in this method. To remove pool dictionaries, global variables, or shared variables declared by the application, see the wasRemovedCode: method.
Last modified date: 01/29/2015