Where to declare variables
Scope
You determine the scope of a PowerScript variable by selecting
where you declare it. Instance variables have additional access
keywords that restrict specific scripts from accessing the variable.
The following table shows the four scopes of variables.
|
Scope |
Description |
|---|---|
|
Global |
Accessible anywhere in the application. |
|
Instance |
Belongs to an object and is associated |
|
Shared |
Belongs to an object definition and exists Shared variables are always private. They are accessible only |
|
Local |
A temporary variable that is accessible |
Global, instance, and shared declarations
Global, instance, and shared variables can be defined in the
Script view of the Application, Window, User Object, or Menu painters.
Global variables can also be defined in the Function painter:
-
Select Declare from
the first drop-down list in the Script view. -
Select the type of variable you want to declare
in the second drop-down list of the Script view. -
Type the declaration in the scripting area of the
Script view.
Local declarations
You declare local variables for an object or control in the
script for that object or control.
Declaring SQL cursors
You can also declare SQL cursors
that are global, shared, instance, or local. Open a specific script
or select a variable declaration scope in the Script view and type
the DECLARE SQL statement
or select Paste SQL from the
PainterBar or pop-up menu.