Maptitude GISDK Help |
You use a for statement to create loops based on a counter variable:
for variable = start_value to finish_value [step step_size] do
<statements go here>
end
The start_value, finish_value, and step_size must all be numeric. For example:
for i = 1 to 10 do
arr[i] = i * i
end
for j = 20 to 0 step -2.5 do
RunMacro("check distance", j)
end
The contents of the loop are executed once for each value of the looping variable. The looping variable is initialized to start_value and compared to finish_value each time the GISDK macro is about to enter the loop. If the looping variable has passed finish_value, the loop terminates. If start_value is greater than finish_value, therefore, the contents of the loop will not be executed at all (unless the step_size is negative).
You can use a break statement to exit the smallest enclosing loop. For example:
for i = 1 to 10 do
ShowMessage("i="+String(i))
if i = 5 then break // only the first five messages will be displayed
end
You can use a continue statement to go to the next iteration of the smallest enclosing loop. For example:
for i = 1 to 10 do
if i > 5 then continue // the last five messages will not be displayed
ShowMessage("i="+String(i))
end
You can also iterate over a collection, similar to foreach loops in other languages:
for item in collection do
<statements go here>
end
where item is a variable name that gets assigned the next element of the collection on each pass through the loop. You should not use this statement when the set of elements contained by the collection changes during the execution of the loop.
The collection can be any of the following:
Collection Type |
Items |
Notes |
Array |
Elements |
|
Vector |
Elements |
|
String |
Characters |
|
File |
Lines |
Must be opened in text mode |
COMObject |
Elements |
Must have an enumerator property that supports the IEnumVARIANT interface |
ManagedObject |
Elements |
Must implement the IEnumerable interface |
DataCursor |
Records |
|
MatrixCurrency |
Vectors |
|
©2025 Caliper Corporation | www.caliper.com |