Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In MapInfo you can edit one table at a time.

How can I programmatically get the name or ID number of the table that is currently being edited?

I tried the following function:

Function GetEditableTable as String
  Dim i, j, WinID as integer
  Dim TableList() as String
  i = NumTables()
  ReDim TableList(i)

  WinID = FrontWindow()
  For j = 1 to i
    Note LayerInfo(WinID, j, LAYER_INFO_EDITABLE)
    If LayerInfo(WinID, j, LAYER_INFO_EDITABLE) = TRUE Then
      GetEditableTable = TableInfo(j, TAB_INFO_NAME)
      Exit Sub
    End If
  Next
End Function

...but it returns the same table name no matter which table is editable.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I use a function like this:

Function MAPGetEditLayerName(ByVal nMID As Integer) As String

Dim nEditLayerID As Integer

MAPGetEditLayerName = ""

    nEditLayerID    = MapperInfo(nMID, MAPPER_INFO_EDIT_LAYER)
    Do Case nEditLayerID
        Case -1
            '**No editable layer currently
        Case 0
            '**The cosmetic layer is currently editable
            MAPGetEditLayerName = LayerInfo(nMID, nEditLayerID, LAYER_INFO_NAME)
        Case Else
            MAPGetEditLayerName = LayerInfo(nMID, nEditLayerID, LAYER_INFO_NAME)
    End Case

End Function

One problem with your function is that you loop over the number of open tables and not the number of layers in the map.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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