DEFINE CLASS

From Lianjapedia
Revision as of 07:00, 7 April 2017 by Yvonne.milne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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(), COMPOBJ(), CREATEOBJECT(), DISPLAY CLASSES, DODEFAULT(), FOREACH, LIST CLASSES, LOADOBJECT(), NEW Operator, NEWOBJECT(), OBJECT(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), RAISEEVENT(), 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 = "Lianja App Builder"
    version = "1.0"
enddefine