CLASS - Properties

From Recital Documentation Wiki
Jump to: navigation, search

Purpose

Create properties in a user-defined class


Syntax

PROPERTY <memvar> | <array> | <dynamic array> [, ...]

[AS CHARACTER | NUMERIC | LOGICAL | DATE | <class>] [, ...]


See Also

ACLASS(), ADDPROPERTY(), AMEMBERS(), CLASS, CLASS - Methods, CLASS - Parameters, CLASS - Scoping, 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 PROPERTY command is used inside the CLASS...ENDCLASS construct to define properties of a class. The PROPERTY command can create memory variables, arrays, and dynamic arrays. You reference properties in an object using the dot (.) member access operator. The full syntax is <object>.<property>.

The visibility of the properties of an object is governed by their scope. Unless otherwise specified, all properties defined within a class are public.

<memvar> | <array> | <dynamic array>

The property name is either a memory variable name <memvar>, or an array name <array>. Arrays are defined with the "arrayname[<expN>]" construct. The <expN> represents the number of array elements, if the number is not specified then the array is defined dynamic.

AS CHARACTER | NUMERIC | LOGICAL | DATE

The data type of values assigned to a property within an object can be checked at run-time by associating a data type with the property in the class definition. The AS clause is used to perform data scoping. Once a variable has been defined as a specific data type, you cannot change its data type by assigning it a value from a different data type: doing this will result in the run-time error "Data type mismatch".

AS <class name>

A property data type can inherit a class <class name>, and its members and their implementation from another class. Inheritance enables developers to build a hierarchy of descendant objects. The specification of a property data type as an existing class name provides for construction of a class hierarchy. The inheriting class is called a derived class, and the class that the derived class inherits is called a base class.


Example

// Example of Properties
class Company 
    property cCOMPANY_NAME as character
    property cCOMPANY_CODE as character
    property aADDRESS[]
    property cCOUNTRY as character
    property cWWW
    property cTEL
    property cFAX
endclass 
 
oCOMPANY = new Company()
oCOMPANY.cCOMPANY_NAME = [Recital Corporation Inc]
oCOMPANY.aADDRESS.line1 = [85 Constitution Lane]
oCOMPANY.aADDRESS.line2 = [Danvers]
oCOMPANY.aADDRESS.line3 = [MA 01923]
oCOMPANY.cWWW = [http:/www.recital.com]
display memory


Products

Recital Server, Recital