[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
EXPORT, PROTECTED .. Determine the scope of an Instance Var or Method
------------------------------------------------------------------------------
SYNTAX:
[ EXPORT: | PUBLIC: ]
[ PROTECTED: | PROTECT: | READONLY: ]
[ HIDDEN: | HIDE: | LOCAL: ]
DESCRIPTION:
This keywords define the default scope and visibility of all Data and
Methods definitions to follow.
Defining Data and Methods as PROTECTED or HIDDEN gives us the tool to
encapsulate our class, one of the key features of OOPs. Please note,
that you can override the default scope by adding a PUBLIC, READONLY
or LOCAL statement to the definition of each var and class var.
EXPORT: or PUBLIC:
This is the default setting. It declares all Methods, Vars and ClassVars
as public, which means, that they can be invoked and accessed from inside
the classes Methods as well as from an outside function, using a
reference to an object of this class :
+--------------------------------------------------------------+
| /* PUBLIC vars */ |
| nA := ::nResult // valid (inside a Method) |
| nA := oDlg:nResult // valid (anywhere) |
| oDlg:nresult := 1 // valid (assign from anywhere) |
+--------------------------------------------------------------+
PROTECTED: or READONLY:
This allows reading and writing of instance variables from a method of
the class, but rejects any writing to a var from the outside. Any attempt
to do so will produce an Error with code 2.
+--------------------------------------------------------------+
| /* PROTECTED Vars */ |
| nA := ::nResult // valid (inside a Method) |
| nA := oDlg:nResult // valid (anywhere) |
| oDlg:nresult := 1 // Prohibited ! |
+--------------------------------------------------------------+
LOCAL: or HIDDEN:
This is the most restricted form. LOCAL Data and Methods are not visible
outside of the class, which limits their usage to the classes methods
only. Any attempt to assign / access a LOCAL Data, or invoke a LOCAL
Method will result in an Error Code 1 or 3.
+--------------------------------------------------------------+
| /* HIDDEN Vars */ |
| nA := ::nResult // valid (inside a Method) |
| nA := oDlg:nResult // Prohibited ! |
| oDlg:nresult := 1 // Prohibited ! |
+--------------------------------------------------------------+
See Also:
VAR, DATA
CLASSVAR, CLASSDATA
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson