Hi list
I usually use For Next loop to test wheter on not a table is open

Sample code is as follows...

declare sub IsTableOpen(byval myTable as string)
declare sub anything
declare sub main

global L_TableOpen as logical
Global myTable as string

sub main

end sub

Sub anything

call IsTableOpen("World")
If  L_tableopen then
    print "Yes, " + myTable +"  is open!"
end if

End sub


Sub IsTableOpen

dim k as integer
L_TableOpen = 0
for k = 1 to NumTables()
    if  Tableinfo(k,1) = mytable then
        L_TableOpen = 1
    end if
next


End Sub


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, March 06, 2000 9:29 AM
Subject: Re: MI Determining if a table is open in MB





Hi Tim,

The easiest way to determine whether or not a table is open, is as you
mention
your self to use the TableInfo() function, which will give an error if the
table isn't open.

And because this question might be asked over and over again, I would say
that the
best thing to do is to put this question inside a function that returns
TRUE if the table is
open and FALSE if not.

This means that you can use this function in the same way yhat you use
FileExists().

Here is that function:

'**************************************************************************
**************************
'    Is table szTab open
'**************************************************************************
**************************
Function TableOpen(ByVal szTab As String) As Logical

Dim i As Integer

TableOpen = False

OnError GoTo NoSuchTable

     '***If you are asking for the Selection table, this question is
nessessary...
     If szTab = "Selection" Then
          If SelectionInfo(SEL_INFO_NROWS) = 0 Then
               Exit Function
          End If
     End If

     '*** If the table isn't open, an error will occure...
     i = TableInfo(szTab,TAB_INFO_NUM)
     '*** The table is open...
     TableOpen = TRUE

     OnError GoTo 0

     Exit Function

'-------------
NoSuchTable:
     '***The table is NOT open...

End Function
'**************************************************************************
**************************


I hope this will help you on with your project !

Best regards,

Peter

***************************************************************************
*
Peter Moller        [EMAIL PROTECTED]
GIS-Developer       Direct: +45 6313 5008
Kampsax Geoplan     Voice: +45 6313 5013
Rug�rdsvej 55       Faximile: +45 6313 5090
DK 5000 Odense C    Web: www.mapinfo.dk
MapInfo Authorized Partner
***************************************************************************
*


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