1

I have a custom menu that I created which opens a mappable table and I'm trying to work out how I open it when

  1. there is no other .tab files or mapper windows open
  2. there are other .tab files open which are in a mapper.

My question relates to the syntax of how I test if there is a mapper open. I then need to use the results of the test to work out whether I use 'map from' or 'add map'.

3

The best approach is to write a function that tests all open windows and checks if they are a mapper or not. If it finds a mapper it returns the window ID otherwise it returns 0. I haven't tested this but this should do it:

Include "MapBasic.def"

Declare Sub Main
Declare Function IsMapperOpen() as Integer

Sub Main()

Dim nWinID as Integer

    nWinID = IsMapperOpen()

    If nWinID > 0 then
        Note "A map window with ID " & nWinID & " is open"
    Else
        Note "No map window open"
    End if

End Sub


Function IsMapperOpen() as Integer

Dim numWins, i as Integer

    numWins = NumWindows()
    i = 0
    Do While(i < numWins)
        i = i + 1
        If WindowInfo(i, WIN_INFO_TYPE) = WIN_MAPPER then
            IsMapperOpen = WindowInfo(i, WIN_INFO_WINDOWID)
            Exit Function
        End If
    Loop

    IsMapperOpen = 0

End Function

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.