Instance variables have access settings that provide control over how other objects’ scripts access them.
You can specify that a variable is:
For example:
public integer ii_currentvalue CONSTANT public integer WARPFACTOR = 1.2 protected string is_starship // Private values used in internal calculations private integer ii_maxrpm private integer ii_minrpm
You can further qualify access to public and protected variables with the modifiers PRIVATEREAD, PRIVATEWRITE, PROTECTEDREAD, or PROTECTEDWRITE:
public privatewrite ii_averagerpm
One use of access settings is to keep other scripts from changing a variable when they should not. You can use PRIVATE or PUBLIC PRIVATEWRITE to keep the variable from being changed directly. You might write public functions to provide validation before changing the variable.
Private variables allow you to encapsulate an object’s functionality, which means that an object’s data and code are part of the object itself and the object determines the interface it presents to other objects.
For more about access settings, see the chapter about declarations in the PowerScript Reference.
For more about encapsulation, see Chapter 1, “Implementing Object-Oriented Programming Techniques.”