In fact, if you want to check for query table or not, too....

If NumTables() > 0 Then
   For nCntr = 1 To NumTables()
      If TableInfo(nCntr, TAB_INFO_TEMP) Then
         Note "Temporary table"
      ElseIf TableInfo(nCntr, TAB_INFO_NAME) = szTableName Then
         nNumRows = TableInfo(nCntr, TAB_INFO_NROWS)
      End If
   Next
End If


Yas
Software Engineer
voice: (918) 877.6704 or (800) 727.6774
fax:   (918) 877.6960
web:   http://www.mpsisys.com
email: [EMAIL PROTECTED]


-----Original Message-----
From: Crompton, Mark [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 17, 2000 1:56 PM
To: 'Tony Kelava'; [EMAIL PROTECTED]
Subject: RE: MI Tables


Hi Tony,

If you do not have too many tables open, and do not check often, try a loop
querying all open tables.  This one below should work.  If you want to check
'QUERYn' Tables, replace the TableInfo with Left$(....,5) = "Query"

I use a similar function to remove several tables I constantly open and
close.

Mark
****************************************************************************
******************
Function IsTableOpen(szMyTableName As String) As Logical
Dim snNumTables, snLoop As SmallInt
Dim bBoolCheck As Logical

        bBoolCheck = 0
        snNumTables = NumTables()
        If snNumTables > 1 Then
                For snLoop = 1 to snNumTables
                        If TableInfo( snLoop, TAB_INFO_NAME) = szMyTableName
Then
                                bBoolCheck = 1
                        End If
                Next
        End If

        IsTableOpen = bBoolCheck
End Function
****************************************************************************
******************


-----Original Message-----
From: Tony Kelava [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 16, 2000 4:24 PM
To: [EMAIL PROTECTED]
Subject: MI Tables


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]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to