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
End Function

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


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.

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