CLASS - Scoping

From Recital Documentation Wiki
Revision as of 16:33, 18 March 2009 by Yvonnemilne (Talk | contribs)

Jump to: navigation, search

CLASS - Scoping

Class

Objects


Purpose

Specify scoping in user-defined class


Syntax

LOCAL | PRIVATE | PUBLIC | STATIC [NOTIFY] [PROPAGATE] :


See Also

ADDPROPERTY(), CLASS, CLASS – Methods, CLASS – Parameters, CLASS – Properties, CREATEOBJECT(), DEFINE CLASS, DODEFAULT(), METHOD, NEWOBJECT(), REMOVEPROPERTY()


Description

The visibility of the properties of an object is governed by their scope. The default visibility is public, but this can be changed by using one of the scoping commands. Once the scope is changed, it remains in effect on all property and method definitions that follow, until it is changed again or the ENDCLASS command is reached.


Scope Description
LOCAL Local properties and methods are visible only to the object where they are defined.
PRIVATE Private properties and methods are visible only to the object where they are defined and to all methods and properties of objects called by the object.
PUBLIC Public properties and methods are visible everywhere.
STATIC Static property values are shared by all objects of the same class.


NOTIFY

The Recital/4GL supports what is known as Property notification. If you specify the NOTIFY clause all properties defined will have 'notify' set. Property notification is an essential element in the real-time interaction with system objects. When a property that has been defined with the NOTIFY clause is read, and the class contains a method called GETPROPERTY, that method is called. The property name is passed to the GETPROPERTY method as a parameter. When a property that has been defined with the NOTIFY clause is updated, and the class contains a method called SETPROPERTY, that method is called. The property name and the new value are passed to the SETPROPERTY method as parameters.

PROPAGATE

Any methods called, which have the PROPAGATE attribute set, cause a cascading execution effect down through the class hierarchy. After the method is executed, a search is made in all of the sub-objects (if any) that are defined as properties within the current object. If a method with the same name is found and that method has the NOTIFY attribute specified, then that method is called.

The CONSTRUCTOR and the DESTRUCTOR methods always act as if sub-objects have the PROPAGATE and the NOTIFY attributes set. This means that any properties that have been specified as sub-objects operate correctly when an object is created with the NEW operator.

:

The colon (:) is used to terminate the property scoping command. All properties following will now have the visibility of the specified scoping command, until a new scoping command is specified or the ENDCLASS is reached.


Example

// Use of Scope Options
class myclass 
public:
property cPUBLIC_PROPERTY
 
method Show  && Publicly available method
//...
return  && Show
 
private:
property cPRIVATE_PROPERTY
local:
property cLOCAL_PROPERTY
static:
property cSTATIC_PROPERTY 
endclass
 
oMyObj = New myclass()
display memory


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer