Maptitude GISDK Help

Class Macros

 

A class can define any number of class macros using the following syntax:

 

Macro "Macro name" {(argument1, argument2, ...)} do

     <statements go here>

endItem

 

Macro names are case sensitive, and can contain any combination of letters, numbers, and spaces. If you do have spaces in the name, you will need to put square brackets around the name when calling the macro. Macros are called using the following syntax:

 

result = obj.MacroName({argument1, argument2, ...})

result = obj.("Macro name")({argument1, argument2, ...})

 

A Class macro can return a result using the function Return().

 

Within a class macro, you can call other class macros using the following syntax:

 

result = self.MacroName({argument1, argument2, ...})

 

If a method call returns another object you can string together a call to a method on that object (or reference a property on it) using the dot notation, with the following syntax:

 

object.GetAnotherObject().DoSomething()

 

All variables defined within a class macro have local scope. You will need to declare variables explicitly as shared in each class macro that they are referenced to have those variables be available in more than one class macro. Here is an example of a class macro using a shared variable:

 

Class "Area" (coords)

 

     Init do

          shared shapepoints

 

          shapepoints = coords

          endItem

 

     Macro "size" do

          shared shapepoints

 

          size = GetPolygonArea(shapepoints)

          Return (size)

          endItem

 

endClass

 

Macro "Create and Report on an Area Object"

 

     // Create the area object

     dim coords[5]

     coords[1] = Coord(-71211737, 42330501)

     coords[2] = MoveAlongGreatCircle (coords[1], 45, 1)

     coords[3] = MoveAlongGreatCircle (coords[2], 135, 1)

     coords[4] = MoveAlongGreatCircle (coords[3], 215, 1)

     coords[5] = coords[1]

     myArea = CreateObject("Area", coords)

 

     // Use the size class macro

     ShowMessage("The size of the area is " + String(myArea.size()) + " " +

          GetMapUnits("Plural"))

 

endMacro

 

 

©2025 Caliper Corporation www.caliper.com