And I also think you need to make sure if a table is used in a graph or browser
window as well:
for window_num = 1 to NumWindows()
Window_ID = WindowID(window_num)
do case WindowInfo(Window_ID,WIN_INFO_TYPE)
case WIN_MAPPER
for i = 1 to MapperInfo(Window_ID,MAPPER_INFO_LAYERS)
for j = 1 to numtabs
if TableNames(j) =
LayerInfo(Window_ID,i,LAYER_INFO_NAME) then
InUse(j) = True
end if
next
next
case WIN_BROWSER, WIN_GRAPH
for j = 1 to numtabs
if TableNames(j) =
WindowInfo(Window_ID,WIN_INFO_TABLE) then
InUse(j) = True
end if
next
case WIN_LAYOUT
end case
next
Peter Horsb�ll M�ller
GIS Developer
Geographical Information & IT
COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark
Tel +45 6311 4900
Direct +45 6311 4908
Mob +45 5156 1045
Fax +45 6311 4949
E-mail [EMAIL PROTECTED]
http://www.cowi.dk/gis
-----Original Message-----
From: Driver, Greg 9434 [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 15, 2004 5:21 PM
To: 'Jay C Russell'; [EMAIL PROTECTED]
Subject: RE: MI-L WinClosedHandler Closing Tables Bug
Jay,
Looking at your code the last for..next loop will close ALL open tables because
you not testing if the inUse() flag has been set for each table. If you change
it to the following it should work (MapInfo doesn't crash and the tables are
closed):
For i = 1 to numtabs
If NOT InUse(i) Then
close table TableNames(i)
print "Table "+TableNames(i)+" closed"
j = j+1
End If
Next
HTH
Greg Driver
-----Original Message-----
From: Jay C Russell [mailto:[EMAIL PROTECTED]
Sent: 15 December 2004 15:45
To: [EMAIL PROTECTED]
Subject: MI-L WinClosedHandler Closing Tables Bug
I was attempting to use the code posted by Uffe at
www.routeware.dk/download/close_unused.zip to close any unused tables when I
close a Mapper window. Unfortunately, it seems like closing any tables which
were on the window being closed produces a crash for Mapinfo 99% of the time.
I am using Windows 2K and Mapinfo 7.8
The errors can be reproduced by using the code below and closing a mapper
window.
Any help appreciated.
Thanks,
Jay Russell
Sub WinClosedHandler
Call CloseUnused
End Sub
Sub CloseUnused
OnError Goto CloseImageTableError
Dim window_num As SmallInt
Dim numTabs,i,j,Window_ID as integer
Dim TableNames(1) as string
Dim InUse(1) as logical
numTabs = NumTables()
Redim TableNames(numTabs)
Redim InUse(numTabs)
For i = 1 to numtabs
TableNames(i) = TableInfo(i,TAB_INFO_NAME)
InUse(i) = False
Next
for window_num = 1 to NumWindows()
Window_ID = WindowID(window_num)
do case WindowInfo(Window_ID,WIN_INFO_TYPE)
case WIN_MAPPER
for i = 1 to MapperInfo(Window_ID,MAPPER_INFO_LAYERS)
for j = 1 to numtabs
if TableNames(j) = LayerInfo(Window_ID,i,LAYER_INFO_NAME) then
InUse(j) = True
end if
next
next
case WIN_BROWSER
case WIN_LAYOUT
case WIN_GRAPH
end case
next
j = 0
For i = 1 to numtabs
close table TableNames(i)
print "Table "+TableNames(i)+" closed"
j = j+1
Next
print j+" tabels closed in total"
Exit Sub
CloseImageTableError:
Note "WinClosedHandlerError:" + Error$()
End Sub
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com | To
unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 14568
Internet communications are not secure and therefore Surrey Police does not
accept legal responsibility for the contents of this message. This email and
any attachments may be confidential. They may contain privileged information
and are intended for the named addressee (s) only. They must not be distributed
without our consent. If you are not the intended recipient, please notify us
immediately and delete the message and any attachments from your computer, do
not disclose, distribute, or retain this email or any part of it. Unless
expressly stated, opinions in this email are those of the individual sender,
and not of Surrey Police. We believe but do not warrant that this e-mail and
any attachments are virus free. You must therefore take full responsibility for
virus checking. Surrey Police reserves the right to monitor all email
communications through their networks.
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 14575