Difference between revisions of "DEFINE CLASS"

From Recital Documentation Wiki
Jump to: navigation, search
(PROTECTED)
Line 53: Line 53:
 
This adds the specified object to the class definition from a Visual FoxPro base class, a user-defined class or an ActiveX custom control.
 
This adds the specified object to the class definition from a Visual FoxPro base class, a user-defined class or an ActiveX custom control.
  
====PROTECTED====
+
 
This affects the properties of the object and ensures that they cannot be accessed or changed outside the scope of the current class or subclasses based on this class.
+
  
 
====AS <base class>====
 
====AS <base class>====

Revision as of 23:44, 15 June 2009

Class

Objects


Purpose

Create a user-defined class


Syntax

DEFINE CLASS <class name> [AS <base class> | CUSTOM [OLEPUBLIC]]

[[PROTECTED | HIDDEN PropertyName1, PropertyName2 ...]

[<object>.]<property> = <exp> ...]

[ADD OBJECT [PROTECTED] <object name>; AS <base class> [NOINIT]

[WITH <property-list>]]...

[[PROTECTED | HIDDEN] FUNCTION | PROCEDURE <proc-name>[_ACCESS | _ASSIGN]

| THIS_ACCESS [NODEFAULT]

<command statements>

[ENDFUNC | ENDPROC]]...

ENDDEFINE


See Also

CLASS, LOCAL, METHOD, PRIVATE, PUBLIC, SET COMPATIBLE, STATIC


Description

The DEFINE CLASS command is the Visual FoxPro class definition command. Within the DEFINE CLASS...ENDDEFINE block all aspects of the class – its name, events, methods and properties can be specified. The CREATEOBJECT() function is used to create an object based on a defined class.

The <class name> defines the reference for the class.

AS <base class> | CUSTOM [OLEPUBLIC]

The AS <base class> clause is used to specify the parent system class for the current class being defined. To specify a user-defined class, use CUSTOM. If the OLEPUBLIC keyword is included, this means that the class in an Automation server can be accessed by an Automation client.

PROTECTED

This affects subsequent property declarations and ensures that PROTECTED properties cannot be accessed or changed outside the scope of the current class or subclasses based on this class.

HIDDEN

This affects subsequent property declarations and ensures that HIDDEN properties cannot be accessed or changed outside the scope of the current class, not even by sub-classes.

Member Declaration <property> = <exp>

Properties can be assigned values when an object based on this class is instantiated by including the assignments in the class definition.

ADD OBJECT <object name>

This adds the specified object to the class definition from a Visual FoxPro base class, a user-defined class or an ActiveX custom control.


AS <base class>

The AS <base class> clause is used to specify the class on which the object is based.

NOINIT

If the NOINIT keyword is specified, the init method of the object will not be called when the object is added.

WITH <property-list>

The WITH <property-list> clause specifies the object's properties and their values. The <property-list> consists of comma separated property=value pairs.

FUNCTION | PROCEDURE <proc-name>

<command statements>

ENDFUNC | ENDPROC

The FUNCTION or PROCEDURE clause is used to define the class's events and methods. The <command statements> are the operations to be performed. The FUNCTION or PROCEDURE can optionally be terminated with the appropriate ENDFUNC or ENDPROC command. Events and methods are called using the object.method | object.event syntax.

_ACCESS | _ASSIGN

If the _ACCESS or the _ASSIGN suffix is added to the name of a procedure or function, this will create an ACCESS method or an ASSIGN method for the property with the same name. ACCESS methods are called whenever the property value is requested and ASSIGN methods are called whenever the property value is changed.

THIS_ACCESS

If THIS_ACCESS is specified the procedure or function will be called whenever an attempt is made to change the value of a member of an object and whenever a member of an object is queried.

NODEFAULT

Including the NODEFAULT keyword prevents the default event or method being performed.

ENDDEFINE

The class definition is terminated with the ENDDEFINE command.


Example

define class myClass as custom
    productname = "Recital Mirage"
    version = "3.0"
enddefine


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer