A18.6 Programming of MMmacro - LUPMISManual

Go to content

Main menu:

Annexes 11-20 > A18. Programming

A18.6 Programming of MMmacro Commands

Level of expertise required for this Chapter: Expert / Programmer; general Map Maker training

For all commands listed in Annex 18.5, Map Maker has to run in the background.

This Annex will give some advice and samples, how to integrate MMmacro commands in your application environment in Visual Basic (VB, possibly bundled with MS Access) and in php (possibly bundled with MySQL, as done at LUPMIS).

- - - - -

A18.6.1 VB

In an application setup, it is recommended to check, if Map Maker is running, by running a dummy command; otherwise Map Maker has to be loaded.

For example, following VBA code in MS Access checks in LUPMIS-Permit Database:

Private Sub check_and_load_MM()
   Dim strSource, strTarget, strQuote, str1Name, str2Name As String

   strSource = "C:\LUPMIS\Permits\Support\DummyforMMrunning.dra"
   strTarget = "C:\LUPMIS\Permits\Temp\Temp_MMchecked.csv"
   str1Name = "C:\Map Maker\MMmacro.exe"
   str2Name = "command=convert file,source=" & strSource & ",target=" & strTarget
   strQuote = Chr$(34)
   If Dir(strTarget) <> "" Then Kill strTarget

   Id_shell = Shell(strQuote & str1Name & strQuote & Space(1) & strQuote & _
                                            str2Name & strQuote, 4)
   If Dir(strTarget) <> "" Then
      Kill strTarget
      Id_shell = Shell("C:\Map Maker\MMM.exe", vbMinimizedNoFocus)
   End If
End Sub

- - - - -

All commands in GEO layer definitions can be used.

Example 1:
command=add layer,directory=C:\LUPMIS\Kasoa\,file1=landuse.DRA,file2=roads.DRA,file type=DRA,files=2,label=Display label,name=roads,style choice=internal,styles=default

Example 2:
…. hit-able=yes,on hit=default…

- - - - -

In some calling environments, double inverted commas (“) have to be set, for example in MS Access:

str3Name = "command=add layer,filename=C:\LUPMIS\Kasoa\Kasoa  SL\"
str4Name = “Odup Sector12.dra"
str5Name = ",name=Sector,label=Display label"
str6Name = ",database=C:\LUPMIS\"Kasoa\Kasoa SL\Odup Sector12_SitePlan.dbf,link column=IDDRA,data column=style"
str7Name = ",style choice=data,styles=C:\LUPMIS\Permits\Support\Lines_siteplan.stl"
strQuote = Str$(34)
str2Name = str3Name & str4Name & str5Name & str6Name & str7Name
Id_shell = Shell(strQuote & str1Name & strQuote & Space(1) & strQuote & str2Name & strQuote, 4)

More examples in Annex 18.4

- - - - -

After calling MapMaker through MMmacro, focus is set to Map Maker window. Depending on the calling software / platform, the focus has to be reset. This can be done:

  • Either, through a command option ‘MinimizedNoFocus’ at the Shell (difficult handling in some platforms)

  • Or, through focus back to MS Access (in VBA: Me.SetFocus, after the Shell command.

- - - -

A18.6.2 php

Integration of MMmacro commands in a php environment is very similar, even easier:

Example to add a layer into Map Maker display:

$str1Name = "C:\\Map Maker\\MMmacro.exe";
$file_selected = "C:\\LUPMIS\\Ghana\\Ghana_roads.dra";
$str2Name = "command=add layer,filename=".$file_selected;

Or, to convert a DRA file to a LOC file, which is easier to read in php:

$str1Name = "C:\\Map Maker\\MMmacro.exe";
$file_source = "C:\\LUPMIS\\Ghana\\Ghana_roads.dra";
$file_target = "C:\\LUPMIS\\Ghana\\temp.loc";
$str2Name = "command=convert file,source=".$file_source.",target=".$file_target;

The tricky part is, that php execution does not wait, till Map Maker completed the execution of the command of MMmacro. A waiting loop might (!) have to be included in php, if the php flow requires an input from MMmacro:

$time_now = time();
while (time() < $time_now + 1){
        // just wait, so MMmacro can finish its job

1 (in line 2) stands here for a 1 second wait; this can be adjusted accordingly.

- - - - -

Note: Requirement: Map Maker version of 12 November 10 or later, and MMmacro.exe of 11 June 09 or later. See also official  Technical Paper 8 of Map Maker.


Back to content | Back to main menu