Declaring instance variables
Often, data needs to be accessible in several scripts within a
window. For example, assume a window displays information about one
customer. You might want several CommandButtons to manipulate the
data, and the script for each button needs to know the customer’s ID.
There are several ways to accomplish this:
-
Declare a global variable containing the current customer
IDAll scripts in the application have access to this
variable. -
Declare an instance variable within the window
All scripts for the window and controls in the window have
access to this variable. -
Declare a shared variable within the window
All scripts for the window and its controls have access to
this variable. In addition, all other windows of the same type
have access to the same variable.
When declaring variables, you need to consider what the scope of
the variable is. If the variable is meaningful only within a window,
declare it as a window-level variable, generally an instance variable.
If the variable is meaningful throughout the entire application, make
it a global variable.
For a complete description of the types of variables and how to
declare them, see the section called “Declaring variables” in PowerScript Reference.