Вы находитесь на странице: 1из 4

Question based tutorial requires Pro

Question: I want to set up Map Maker so that when I click on an object it sends data
about the object to a separate program. What are my options? .
There are a number of options. The first thing to decide is do you want to:
a).
specify the link for each object one at a time, or
b)
do you want to link all the objects in the layer to an external program in a
single consistent way .
An example of the first option might be an archaeological map where you do not
need all the objects to be linked and different objects may have different needs
some might need to be linked to a database while others might be better linked to a
web page or a graphic. The second option might be a forestry application where you
want to be able to click on each area of woodland so that an external program is
triggered with the ID of the woodland being sent to the external program as a
parameter.
For the first option you should see page 107 of the manual. This paper deals with
linking the whole layer to an external program. This topic is relatively advanced and
requires more understanding of computing.
Choose the DRA file that you want to link to, in this example polygons.dra. In the
Layer set up dialogue box go to Data link On hit Document or link Link
layer EXE. Click on Change program to choose your program, here we have
chosen a program called TestHit.exe.

At the bottom of the dialogue box you can specify what parameters are sent to the
external program. In this example ID and Seed point have been chosen. The
nature of the seed point depends on the type of object. For a point object the seed
point is simply its co-ordinates; for a line object it is the co-ordinates of a point on the

line near its centre; for a polygon it is the co-ordinates of a point guaranteed to be
within the polygon.
Before clicking OK ensure that the Make layer hit-able with the data query tool
check box has been ticked. After clicking OK the layer is displayed. Select the data
query tool and click on an object in our example it might be Zone 104. As a result
of clicking on the object the external program here TestHit.exe is launched. The
program TestHit.exe displays a windows listing the parameters sent to the external
program:

Each parameter starts and ends with double quotation marks in case the parameter
contains spaces. The first parameter is always the number of objects which have
been hit. If you had dragged the Data query to draw a rectangle, for instance, you
might have hit several objects rather than just one. In such a case the external
program is called once for each object hit. The second parameter indicates which
object is referred to from a multiple hit in this case hit 1 of 1.
In addition to selecting options from the list you can specify your own command line
parameters in the field labelled Send parameters in command line. If you also have
items selected in the list then whatever you type into this field will be enclosed in
double quotes and treated as a single parameter. For instance:

In this case where the command line parameter entered by the user is forestry layer
the full set of parameters sent to the external program (TestHit.exe) is:

If no items have been selected from the list then the typed in parameter(s) will be
sent as is, i.e.:
Forestry layer
However, the typed in parameter can contain tokens that is to say variables that
will be converted to their true value on the fly by the program. A token is contained in
a pair of angle brackets < >. So if you typed in:
Forestry layer <ID>
Then this will actually be sent out to the external program as, in this example:
Forest layer Zone 106
Or if you wrote:
Forest layer <ID>
The result would be:
Forest layer Zone 106
There are several tokens that you can use:
<ID>
<label>
<area>
<hectares>
<length>
<seed>
<style>
<file>
<base>
<tempdir>
<dir>
<.dbf>

The object ID
The objects display label
The area of a polygon in square metres
The area of a polygon in hectares
The length of a line or the perimeter of a polygon
The X and Y co-ordinates of the seed point
The internal style number of an object
The DRA file that has been hit
The Map Maker base directory, in other words the
directory where Map Maker is installed, that is to say the
directory containing the file mmm.exe
The directory used for temporary files.
The directory containing the DRA file that has been hit.
Use any file extension preceded by full stop and this will be
replaced by the full filename of the program which
Windows currently has associated with that file extension.
For instance, if DBF files are associated with FoxPro then

<access>
<www>

this will give the full path name of the FoxPro executable.
This is identical to <.mdb>, in other words it gives the full
path name of Microsoft Access if installed.
This is identical to <.htm>, it will launch Internet Explorer or
whatever browser is associated with HTM files.

Note that the various tokens that return directories or full path names return the
results for the users computer so using these tokens introduces some independence
from a specific set up of directories. Note also that the tokens that return directory
names all include the final back slash.
When using tokens you do not necessarily have to first select a program file with the
Change program button. For instance entering the following in the parameter field:
<access> <dir>polygons.mdb
will result in a click on an object launching Microsoft Access and open the database
called Polygons.mdb that is to be found in the same directory as the DRA file that has
been hit. You can go further and use any of the command line options for Access,
such as:
<access> <dir>polygons.mdb /x Macro1 /cmd <id>
This will open the database and then launch the macro Macro1. This macro makes
use of the command line variable which follows the Access command /cmd which in
this case is the Map Maker ID token. The Macro can be set to do anything that
Access can do such as displaying a form or whatever. See the Acces documentation
for more details.
Similarly,
<www> http:\\www.any.net\my.htm?query=<ID>&area=<hectares>
Will launch the specified web page with the ID and the area of the hit object as part of
a query string that can be used by a web-based application.

Вам также может понравиться