Difference between revisions of "DEFINE CLASS"

From Recital Documentation Wiki
Jump to: navigation, search
(Syntax)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=DEFINE CLASS=
 
 
 
==Class==
 
Objects
 
 
 
 
==Purpose==
 
==Purpose==
 
Create a user-defined class
 
Create a user-defined class
Line 11: Line 4:
  
 
==Syntax==
 
==Syntax==
DEFINE CLASS <class name> [AS <base class> | CUSTOM [OLEPUBLIC]]
+
DEFINE CLASS <class name> [AS <base class> | CUSTOM [OLEPUBLIC&#093;]
  
 
[&#091;PROTECTED | HIDDEN PropertyName1, PropertyName2 ...]
 
[&#091;PROTECTED | HIDDEN PropertyName1, PropertyName2 ...]
  
[&#060;object&#062;.]&#060;property&#062; = <exp> ...]
+
[<object>.]<property> = <exp> ...]
  
[ADD OBJECT [PROTECTED] &#060;object name&#062; AS &#060;base class&#062; [NOINIT]
+
[ADD OBJECT [PROTECTED] <object name> AS <base class> [NOINIT]
  
[WITH &#060;property-list&#062;]]...[[PROTECTED | HIDDEN] FUNCTION | PROCEDURE <proc-name>[_ACCESS | _ASSIGN]
+
[WITH <property-list>&#093;]...
 +
 
 +
[&#091;PROTECTED | HIDDEN] FUNCTION | PROCEDURE <proc-name>[_ACCESS | _ASSIGN]
  
 
| THIS_ACCESS [NODEFAULT]
 
| THIS_ACCESS [NODEFAULT]
Line 25: Line 20:
 
<command statements>
 
<command statements>
  
[ENDFUNC | ENDPROC]]...
+
[ENDFUNC | ENDPROC&#093;]...
  
 
ENDDEFINE
 
ENDDEFINE
 
  
 
==See Also==
 
==See Also==
[[CLASS]], [[LOCAL]], [[METHOD]], [[PRIVATE]], [[PUBLIC]], [[SET COMPATIBLE]], [[STATIC]]
+
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[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 53: Line 47:
 
====ADD OBJECT <object name>====
 
====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.
 
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>====
Line 87: Line 78:
 
<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>
Line 94: Line 85:
  
 
==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 12:38, 12 March 2010

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(), 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