Using Run Application "G:\System\SSA\wor\Current\Townplanning_2018_v1\Zoning.wor" that's called from within a mapbasic program I want to load the workspace in the current map view rather than in a new one.

If I have

Dim nWindowID As Integer
nWindowID = FrontWindow()

How can I tell the run application to open in this window? This has to be in v15 32bit and not 64bit.


Here's how I would do it:

First capture the number of open window before opening the workspace:

nNumWindows = NumWindows()

Get the ID of the Map window to add the layers to:

nMID = FrontWindow()

Open the workspace and let it open the windows

Run Application "G:\System\SSA\wor\Current\Townplanning_2018_v1\Zoning.wor"

Find the map window. I just assume it's the last window opened by the workspace

nMIDNew = WindowID(NumWindows())

Now get the close string of the new map window and run it into the existing map

Set Window nMID Front
Run Command MapperInfo(nMIDNew, MAPPER_INFO_MERGE_MAP)

And finally, close the windows opened by the workspace

For nWID = NumWindows() to (nNumWindows + 1) Step -1
   Close Window WindowID(nWID)

I haven't declared any of the variables I have used

| improve this answer | |

A workspace file is basically a list of mapbasic commands. One of them is usually "map from....", which creates a new mapper. If you want it to add to an existing mapper, try to replace it with "add map frontwindow()...". See the help file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.