The DEFINE command can be used to define new methods on user defined or predefined classes. A method is similar to a function, except that it is associated with objects of a particular type (Class).
DEF[INE] METHOD method_name ( arg1, arg2, ... ) ON class_name
command_list ...
ENDDEFINE
The object on which the method is invoked will be known as 'this' within the method.
If the method is named Initialize(), then it will be used as a constructor for the class. It will be automatically invoked each time an object of the class is created. Normally, the constructor is used to assign initial values to the class fields. The Initialize() method cannot take any arguments.
If the method is named Destroy(), then it will be used as a destructor for objects in the class. It will be automatically invoked each time an object of the class is destroyed. Normally, the destructor is used to free any additional memory associated with the class.
Example:
Define a class called Circle with two initialization methods.
DEFINE CLASS Circle
ReadOnly
double CenterX
double CenterY
double Radius
double Area
EndReadOnly
ENDDEFINE
DEFINE METHOD SetCenter( x, y ) ON Circle
this.CenterX = x
this.CenterY = y
ENDDEFINE
DEFINE METHOD SetRadius( new_radius ) ON Circle
this.Radius = new_radius
this.Area = 3.1415927 * this.Radius * this.Radius
ENDDEFINE
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.