Difference between revisions of "CLASS - Scoping"

From Recital Documentation Wiki
Jump to: navigation, search
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=CLASS - Scoping=
 
 
 
==Class==
 
Objects
 
 
 
 
==Purpose==
 
==Purpose==
 
Specify scoping in user-defined class
 
Specify scoping in user-defined class
Line 11: Line 4:
  
 
==Syntax==
 
==Syntax==
LOCAL | PRIVATE | PUBLIC | STATIC [NOTIFY] [PROPAGATE] :
+
LOCAL | PRIVATE | PUBLIC | STATIC :
  
  
 
==See Also==
 
==See Also==
[[ADDPROPERTY()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DODEFAULT()]], [[METHOD]], [[NEWOBJECT()]], [[REMOVEPROPERTY()]]
+
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[METHOD]], [[NEWOBJECT()]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]]
  
  
Line 34: Line 27:
 
|-
 
|-
 
|}
 
|}
 
 
====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.
 
  
  
Line 52: Line 33:
 
// Use of Scope Options
 
// Use of Scope Options
 
class myclass  
 
class myclass  
public:
+
    public:
property cPUBLIC_PROPERTY
+
        property cPUBLIC_PROPERTY
 
+
        method Show  && Publicly available method
method Show  && Publicly available method
+
            //...
//...
+
        return  && Show
return  && Show
+
    private:
 
+
        property cPRIVATE_PROPERTY
private:
+
    local:
property cPRIVATE_PROPERTY
+
        property cLOCAL_PROPERTY
local:
+
    static:
property cLOCAL_PROPERTY
+
        property cSTATIC_PROPERTY  
static:
+
property cSTATIC_PROPERTY  
+
 
endclass
 
endclass
  
Line 73: Line 52:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 +
[[Category:Objects]]
 +
[[Category:Objects Commands]]

Latest revision as of 11:43, 13 January 2010

Purpose

Specify scoping in user-defined class


Syntax

LOCAL | PRIVATE | PUBLIC | STATIC :


See Also

ACLASS(), ADDPROPERTY(), AMEMBERS(), CLASS, CLASS - Methods, CLASS - Parameters, CLASS - Properties, COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, LIST CLASSES, LOADOBJECT(), METHOD, NEWOBJECT(), OBJECT(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), SAVEOBJECT(), SQL SELECT, WITH


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.


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 Server, Recital