Maptitude GISDK Help

Classes

Class resources define classes from which objects are created. An object, stored in an object variable, has properties and can be operated on by macros (often called methods) in its class. Classes can inherit properties and methods from a parent class. The GISDK object framework provides a powerful capability within Caliper Script for implementing object-oriented programming (OOP).

The structure of a class resource is:

{static} Class "Class name" {(argument1, argument2, ...)} {options}

     <statements go here>

endClass

If you declare a class static it can only be called from resources within the same resource file in  

which the class is defined.

Class names are case sensitive, and can contain any combination of letters, numbers, and spaces. A class can have an Init macro that is run when objects are created. You can pass up to eight arguments when you create an object. Those arguments can be referenced as local variables by the class Init macro.

The following GISDK functions can be used when working with objects:

GISDK Function

Summary

CreateObject()

Creates a new object variable based on a class

Return()

Returns from a called GISDK macro or dialog box

GetClassMethodNames()

Returns a list of the names of the methods defined for the class

GetObjectClass()

Gets the name of the class for an object

GetObjectVariableNames()

Gets a list of the variable names for an object

IsKindOfClass()

Determines whether an object is in a class or inherits from that class

ObjectHasMethod()

Determines whether an object's class, or an inherited class, implements a method

Here is an example using a class resource for points. The Init item creates several object properties and the move class macro lets you change the location of the point:

Class "Point" (coord, attributes)

     Init do

          self.coords = {coord}

          self.ID = attributes.ID

          self.name = attributes.name

          endItem

     Macro "lonlat" do

          coord = self.coords[1]

          Return ({coord.lon, coord.lat})

          endItem

endClass

Macro "Create and Report on a Point Object"

     // Create the point object

     loc = Coord(-71211737, 42330501)

     attributes = {}

     attributes.ID = 101

     attributes.name = "Caliper Corporation"

     myPoint = CreateObject("Point", loc, attributes)

     // Use the lonlat class macro and get the object properties

     {lon,lat} = myPoint.lonlat()

     ShowMessage("Point " + String(myPoint.ID) + " (" + myPoint.name +

          ") is at (" + String(lon) + ", " + String(lat) + ")")

     // Get information on the point

     ShowMessage("The object's class is " + GetObjectClass(myPoint))

     ShowArray(GetObjectVariableNames(myPoint))

endMacro

Classes can also define a Done item, which is run when the last reference to the object goes out of scope. The Done item for parent classes will be called after that of its child. The syntax is:

Done do

     <statements go here>

     endItem

For more information, see...

Class Variables

Object Properties

Class Macros

Inheritance

Object-Oriented Programming Example

Controllers for Dialog Boxes

 

 

©2025 Caliper Corporation www.caliper.com