Difference between revisions of "DEFINE CLASS"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
Line 13: | Line 13: | ||
DEFINE CLASS <class name> [AS <base class> | CUSTOM [OLEPUBLIC]] | DEFINE CLASS <class name> [AS <base class> | CUSTOM [OLEPUBLIC]] | ||
− | [ | + | [[PROTECTED | HIDDEN PropertyName1, PropertyName2 ...] |
[<object>.]<property> = <exp> ...] | [<object>.]<property> = <exp> ...] |
Revision as of 11:23, 18 March 2009
Contents
- 1 DEFINE CLASS
- 1.1 Class
- 1.2 Purpose
- 1.3 Syntax
- 1.4 See Also
- 1.5 Description
- 1.5.1 AS <base class> | CUSTOM [OLEPUBLIC]
- 1.5.2 PROTECTED
- 1.5.3 HIDDEN
- 1.5.4 Member Declaration <property> = <exp>
- 1.5.5 ADD OBJECT <object name>
- 1.5.6 PROTECTED
- 1.5.7 AS <base class>
- 1.5.8 NOINIT
- 1.5.9 WITH <property-list>
- 1.5.10 FUNCTION | PROCEDURE <proc-name>
- 1.5.11 ENDFUNC | ENDPROC
- 1.5.12 _ACCESS | _ASSIGN
- 1.5.13 THIS_ACCESS
- 1.5.14 NODEFAULT
- 1.5.15 ENDDEFINE
- 1.6 Example
- 1.7 Products
DEFINE CLASS
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>]]... 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.
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>
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