A17.3 Exercise 3 - LUPMISManual

Search
Go to content

Main menu:

Annexes 11-20 > A17. External exercises

A17.3 Exercise 3

One layer: exercise3. How to send data from this layer to a separate program?

There are a number of options. The first thing to decide is:
Do you want to specify the link for each object one at a time?, or
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 official manual. This Chapter 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-tool from the toolbar left 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>

The object ID

<label>

The objects display label

<area>

The area of a polygon in square metres

<hectares>

The area of a polygon in hectares

<length>

The length of a line or the perimeter of a polygon

<seed>

The X and Y co-ordinates of the seed point

<style>

The internal style number of an object

<file>

The DRA file that has been hit

<base>

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

<tempdir>

The directory used for temporary files.

<dir>

The directory containing the DRA file that has been hit.

<.dbf>

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 this will give the full path name of the FoxPro executable.

<access>

This is identical to <.mdb>, in other words it gives the full path name of Microsoft Access if installed.

<www>

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 Access 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.

- - - - -


See also Chapter 6.9 for external display of features.

    



 
Back to content | Back to main menu