Using Immediate Execution
You can use the Immediate Execution dialog box to type Caliper Script commands and have them executed immediately. Maptitude writes the commands to a resource file as a GISDK macro, compiles the resource file, and runs the macro. The dialog box has the following buttons:
| Button/Checkbox | Description |
|---|---|
| Run | Runs the Caliper Script commands |
| Close | Closes the dialog box without running the Caliper Script commands |
| Previous | Loads previous immediate execution commands if several immediate execution commands were run |
| Reload | Changes back to the Caliper Script commands (if any) that were in the dialog box when you last closed it |
| Next | Loads the next immediate execution command |
| Clear | Clears Caliper Script commands from the dialog box |
| Help | Opens the Maptitude Help to the topic for the GISDK function that is highlighted or is the word that the cursor is in; for a list of all the GISDK functions, see Listing of GISDK Functions |
| Make the font smaller | |
| Make the font larger | |
| Trace | Displays all the variables created and their values as the code executes |
You can resize the dialog box by dragging any corner or side. There are two font sizes, smaller and larger.
The dialog box is non-modal, so it stays open until you close it by clicking the Close button or the "x" in the top right corner.
There are many cases where immediate execution of a statement is helpful. For example:
| Statement | When to use it |
|---|---|
| ShowMessage() | To display debugging information (e.g., ShowMessage(GetLayer()) to display the name of the current layer; or ShowMessage(state_view.Name) to see the name of the State your GISDK macro loop is working on) |
| SetLayer() | To set the current layer before testing an add-in |
| DestroyProgressBar() | If your GISDK macro accidentally leaves a progress bar on the screen, this statement will get rid of it |
| SetScale() | To change the map scale to an appropriate value |
| RunMacro() | To run a GISDK macro you use for testing or debugging purposes |
Immediate execution can be used to import files, perform selection, read and update data values, and more. However, certain commands may not have the desired effect. Here are a few examples:
The Exit() statement will terminate Maptitude and return you immediately to Windows
Assignment statements will have no effect outside the commands in the immediate execution GISDK macro
The Return() statement will have no visible effect, because it simply returns from the immediate execution GISDK macro
When you enable the Trace option and you write GISDK statements over multiple lines, the result of executing each line will be displayed below your statements.
Here is an example:
{ layer_names , current_idx , current_layer } = GetMapLayers(GetMap(),"Area")
map_layers = layer_names
this_layer = current_layer
for i=1 to layer_names.length do
layer_name = layer_names[i]
end
/*** trace ***
map_layers = { "Australia", "World Country", "Collection District", "Water Area", "Landmark Area", "Building", "State Suburb", "Local Government", "Postal Area", "State" }
this_layer = "Postal Area"
layer_name = "Australia"
layer_name = "World Country"
layer_name = "Collection District"
layer_name = "Water Area"
layer_name = "Landmark Area"
layer_name = "Building"
layer_name = "State Suburb"
layer_name = "Local Government"
layer_name = "Postal Area"
layer_name = "State"
*** trace ***/
To Execute Caliper Script Commands Immediately
- Click
on the GISDK toolbox to display the Immediate Execution dialog box. - Type the statement or statements you want to execute. To advance to the next line, press Enter or Ctrl-Enter. Maptitude starts a new line.
- Click Run to execute the statement or statements.
- Click Close when you are done.