Member functions

Member functions, called methods, are not defined within the class definition itself. Rather, they are defined separately in a manner similar to regular function definitions. All defined methods are global and cannot be declared as private or protected as in some other object-oriented languages.

DEFINE METHOD method_name( arg1, arg2, ...) ON
  class_name
  command list ...
ENDDEFINE

For example, suppose the class Circle has been defined as follows:

DEFINE CLASS Circle
  ReadOnly
    double CenterX
    double CenterY
    double Radius
    double Area
  EndReadOnly
ENDDEFINE

Then a method to set the center of a circle could be defined:

DEFINE METHOD SetCenter( x, y ) ON Circle
  this.CenterX = x
  this.CenterY = y
ENDDEFINE

The special identifier "this" is available automatically in all methods, and is used to access the data fields and other methods of the object being acted upon. Methods are able to access and modify data fields belonging to the objects on which they are invoked regardless of the access restrictions on those fields.

A method is invoked through an object instance using the dot notation in the same fashion as a data reference:

local Circle c
call c.SetCenter(3.0, 5.0)

Like regular functions, methods can take any number of arguments, define local variables, and may return a value. A class can have any number of methods associated with it. The definition of the Circle class can be completed with two methods: one method is to set the circle's radius, and automatically compute the circle's area, and another to calculate and return the circle's diameter:

DEFINE METHOD SetRadius( new_radius ) ON Circle
  this.Radius = new_radius
  this.Area = 3.1415927 * this.Radius * this.Radius
ENDDEFINE
DEFINE METHOD GetDiameter() ON Circle
  return (2*this.Radius)
ENDDEFINE

The following interactive example demonstrates use of the class Circle:

EASI>local Circle c
EASI>call c.SetCenter(3,5)
EASI>print c.Area
0
EASI>call c.SetRadius(5)
EASI>print c.Area
78.5398175
EASI>print c.GetDiameter
10

It is not possible to overload a function name providing different function definitions depending on the number or type of its arguments. It is possible to achieve some of the same affect in a manual way by using functions with variable number of arguments, and the f$partyp() intrinsic to extract type information from arguments.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.