Maptitude GISDK Help |
A macro block (can also be referred to as a lambda expression, or an anonymous macro) is a way to pass some executable code as a parameter to another macro or function which can then execute this code, perhaps also passing some parameters. The macro receives the block as one of its parameters and executes it by calling its "call()" method, optionally including parameters.
The block can also reference local and shared variables from the scope in which it was declared, including the 'self' reference if it is created in a GISDK class method.
A block is defined by the syntax:
do (param1, param2, …)
statements...
end
Macro "PerformOperation" (operation)
Return(operation.call(5, 8))
endMacro
sum = RunMacro("PerformOperation", do (x, y)
Return(x + y)
end)
multiplier = 2
product = RunMacro("PerformOperation", do (x, y)
Return(x * y * multiplier)
end)
//sum = 13
//product = 80
©2025 Caliper Corporation | www.caliper.com |