| Home | Previous Lesson: Global Variables Next Lesson: Instance Variables |
Shared variables are stored in an object's definition and are available for all instances of the object. The first instance of the variable is initialized, when an object that has the shared variable is opened, and exists until the close of the application. The value of the variable persists even if the object is closed.
One example of how you could use this type of variable is when you want to count the number of times an object has been opened in an application. For each instance that is opened, the shared variable is incremented by one and the destruction of the instance has no effect on the value or on the existence of the variable itself.
Shared variables can be declared for an application, menu, window and user objects. Shared variables are declared in the same way as Global variables, but you need to select 'Shared Variables' instead of 'Global Variables' option.
| Home | Previous Lesson: Global Variables Next Lesson: Instance Variables |