Command Line Interface

 

 

 

In addition to the menu commands and shortcut keys there is a command line interface built into Think GIS. Commands can be executed individually or a collection of commands can be combined together to form what is called a script. Scripts can then be used to simplify a complex or repetitive process into a single button or keystroke.

 

To work with commands and scripts the following needs to be understood:

 

What is a command

What is a script

How to manually issue a command in Think GIS

How to run a command from a desktop shortcut

How to automatically run commands on startup

How to create custom buttons that run commands

How to assign commands to function keys

How to pass commands to Think GIS from another application

UDP Command Interface

TCP Command Interface

List of Commands

 

What is a command

A command is a line of text that instructs Think GIS to carry out a specific task such as copy a file, or change the color of a layer. All commands are made up of a command verb followed by some parameters that detail how the action should be carried out.

Example: EraseLayer Roads

 

Command usage rules

A space must separate the command verb from its first parameter (see example above).

All command verbs have no spaces in them (see example above).

If there is more than one parameter then the parameters must be separated by commas. The number and type of parameters varies depending on what command verb is being used.

See List of Commands for a complete list of command verbs and how to use them.

 

Using variables in commands

Commands can contain any of the following variables which get replaced with the appropriate value when they are executed:

%MapDir% Insert path to directory where current map is running from.

%TMDir% Insert path to directory where tm4.exe is running.

%DataDir% Insert data directory for the Current Layer.

%LayerName% Insert layer name for the Current Layer.

<FieldName> When commands are executed from a hyperlink on a form, field name variables may be included. To do this simply enclose the field name in greater than/less than brackets. Field names only get inserted if a Feature form is displayed while the command is being executed.

%Map% Insert name of current map.

%Date% Insert current date in format "mm/dd/yyyy"

%Time% Insert current time in format "hour:min a/p"

%User% Insert user name used to login on the computer.

%Lat% The latitude value of the coordinates last selected using the PickPoint command.

%Lon% The longitude value of the coordinates last selected using the PickPoint command.

 

Using quotation marks ( " ) in commands

Any quotation marks included in a comma delimited list of parameters serves one of two purposes. It can be used to CONTAIN a parameter or it can be PART OF the parameter. Understanding this difference can save a lot of trouble.

 

Using quotation marks to CONTAIN a parameter:

Rule #1: If a comma is included in a parameter then the entire parameter must be enclosed in quotation marks. Consider the following example. To erase the contents of the roads layer, use the command EraseLayer roads . But what if the name of the layer was Cnty,Twp,Inc. When Think GIS goes to parse out this command it would think that there are three different parameters being passed to the EraseLayer command and since this command only takes one parameter it would attempt to erase a layer called Cnty. So the solution is to put the entire parameter in quotation marks. So the command EraseLayer "Cnty,Twp,Inc" would work just fine.

 

Using quotation marks as PART OF a parameter :

Rule #2: If a parameter has a quotation mark in it, then it must also contain the entire parameter in quotation marks and use a double-quotation mark to indicate the literal one. For example, to run a specific section in a script file, one could use the command RunScript import.txt,[section b] . But what if the section name was [section "b"]? Since this example includes a quotation marks as PART OF the parameter, the command RunScript import.txt,"[section ""b""]" will need to be used.

 

What is a script

A script is simply a collection of commands arranged in a specific order that get executed one after the other. The commands are stored in a ASCII or Unicode text file where each line of the file is a command. Scripts are initiated via the RunScript command and therefore a script can be ran from anywhere a command can be ran. The RunScript command can also be one of the commands in the script which allows users to create scripts that run other scripts. There are a few places within Think GIS that link to the Script Editor screen to assist in creating and editing a script.

Example: SetAtt Low Res Photos,Visibility,off

  SetAtt Hi Res Photos, Visibility,on

  RunMenuItem New Feature + Symbol

 

How to manually issue a command in Think GIS

Use the Run Command menu item on the Tools menu. Type the command here and click OK.

 

How to run a command from a desktop shortcut

Think GIS is usually setup with a shortcut on the desktop that looks something like the following:

C:\ThinkGIS\tm4.exe beaufort\beaufort.tgm

In this case the executable name, tm4.exe, is followed by the map name that is to be loaded as soon as Think GIS starts. To execute a command in addition to loading the map, include the command as the third parameter. For example, the shortcut

C:\ThinkGIS\tm4.exe beaufort\beaufort.tgm "RunScript import.txt"

starts Think GIS, loads the beaufort map and then runs the RunScript command. It is important to include the entire command with its parameters in quotation marks so that is treated as a single command line parameter.

 

If any part of the command string contains a quotation mark then the entire command string must be surrounded in quotation marks and use two quotation marks for each contained in the command. For example:

C:\ThinkGIS\tm4.exe beaufort\beaufort.tgm "Popup Call ""555-1234"" for help"

 

How to run commands on startup

Any commands listed in the [Startup] section of the Workstation Settings are automatically executed each time Think GIS starts.

 

How to create custom buttons that run commands

See the Custom button section of the Workstation Settings for instructions on adding custom buttons the Think GIS main menu. Custom buttons operate by executing a specified command each time they are clicked.

 

Users can also specify Layer Specific Buttons for any layer. In this case the buttons only show up when a map containing this layer is opened.

 

How to assign commands to function keys

See Function Key Setup for instructions on assigning one or more commands to a function key.

 

How to pass commands to Think GIS from another application

Think GIS can be configured to automatically poll an external file for commands. Every 2 seconds Think GIS checks to see if the file exists and if so it reads in the commands listed in the file and executes them and then deletes the file. The Think GIS 911 interface module ALIFWD uses this command file interface to pass address lookup commands to each Think GIS workstation. See the command file parameter in Workstation Settings for more information on setting this up.

 

UDP Command Interface

Commands may also be sent to Think GIS via UDP packets. Think GIS listens for command packets on port 46112 by default. If a different port needs to be used a CmdPort line may be added to the tm4.ini to define a different port. Each packet should contain the simple text of a single command with no additional formatting. Only the first instance of Think GIS running on a machine will receive packets. Allow multiple instances of Think GIS should be unchecked in Workstation Settings when using this option.

 

TCP Command Interface

Commands may also be sent to Think GIS via TCP packets. Think GIS listens for command packets on port 46112 by default. If a different port needs to be used a TCPCmdPort line may be added to the tm4.ini to define a different port. Each packet should contain the simple text of a single command with no additional formatting. Only the first instance of Think GIS running on a machine will receive packets. Allow multiple instances of Think GIS should be unchecked in Workstation Settings when using this option.

 

 

 

Copyright © 2024 WTH Technology