One of the samples that comes with MapBasic has a function that returns a layer number.

The test for table being open in current window is then:

if GetLayerNumber(FrontWindow(), YourTableName) > 0

It is probably the hard way to do it.

Cheers


At 09:24 AM 4/17/00 +1000, Tony Kelava wrote:
>How do tell if a table is open in mapbasic?
>
>I've tried
>
> x = TableInfo (tablename , TAB_INFO_NROWS)
>
>but if the table is not open, this halts the mapbasic program, so i tried this:
>
>onerror goto NotOpen
> x = TableInfo (tablename , TAB_INFO_NROWS)
>NotOpen:
>
>BUT, it still halts the program if the table is not open. OnError doesn't
>seem to be trapping all errors.
>
>----------------------------------------------------------------------
>To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
>"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
Declare Function GetLayerNumber(ByVal winId as Integer, ByVal name as String) As 
Integer
 

Function GetLayerNumber(ByVal winId as Integer, ByVal name As String) As Integer
        dim i as smallint

'Get layer number of table passed in
        For i = 1 to MapperInfo(winId, MAPPER_INFO_LAYERS)
           If LayerInfo(WinId, i, LAYER_INFO_NAME ) = name Then
                GetLayerNumber = i
                Exit Function
           End If
        Next
        
End Function


==================================================
Eugene Gridnev
Field Geophysicist
Columbus TX

409 732 9155
==================================================

Reply via email to