Difference between revisions of "DEFINE CLASS"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
Line 1: Line 1:
 
 
==Purpose==
 
==Purpose==
 
Create a user-defined class
 
Create a user-defined class
Line 27: Line 26:
  
 
==See Also==
 
==See Also==
[[CLASS]], [[LOCAL]], [[METHOD]], [[PRIVATE]], [[PUBLIC]], [[SET COMPATIBLE]]
+
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[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==
 
==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 DEFINE CLASS command is used to define a class.  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.
 
The <class name> defines the reference for the class.
Line 80: Line 79:
 
<code lang="recital">
 
<code lang="recital">
 
define class myClass as custom
 
define class myClass as custom
     productname = "Recital Mirage"
+
     productname = "Recital"
     version = "3.0"
+
     version = "10.0"
 
enddefine
 
enddefine
 
</code>
 
</code>

Revision as of 15:03, 14 December 2009

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

ACLASS(), ADDPROPERTY(), AMEMBERS(), CLASS, CLASS - Methods, CLASS - Parameters, CLASS - Properties, 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 DEFINE CLASS command is used to define a class. 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"
    version = "10.0"
enddefine


Products

Recital Server, Recital