Class

The DEFINE command can be used to declare new object classes. Defining a class is similar to defining a structure, except that a class can have special functions called 'methods' associated only with objects (variables) of that class. Classes also support data hiding for data fields.

 DEF[INE] CLASS new_class_name [INHERITS base_class_name]
   field1_type         field1_name[(array_size1)]
   field2_type         field2_name[(array_size2)]
   ...
  [ReadOnly
     fieldn_type       fieldn_name[(array_sizen)]
     ...
   EndReadOnly]
  [Private
     fieldm_type       fieldm_name[(array_sizem)]
     ...
   EndPrivate]
 ENDDEFINE

Note that an array size specifier should not be used if the field is of type String or MString.

The ReadOnly/EndReadOnly and Private/EndPrivate keywords can be used to declare special access restrictions on some data fields. The ReadOnly field can only be updated by methods of the class. Private fields can only be read and updated by methods of the class.

The INHERITS keyword can be used to specify a base class for the newly defined class. If this is done, then all fields and methods previously defined on the base class will be included in the new class. This implements single inheritance. Multiple inheritance is not supported.

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.