Hello Daniel,

You're problem is that when closing a table, the table numbers all change.
i.e. delete #1 and the original #2 becomes #1.

The solution is easy, simply run your loop backwards. This will ensure that
no "close table" operations trip up your code in latter iterations.

for I = Total_Layers to 1 step-1

Regards,
Warren Vick
Europa Technologies Ltd.
http://www.europa-tech.com


-----Original Message-----
From: Daniel York [mailto:[EMAIL PROTECTED] 
Sent: 12 July 2004 09:42
To: [EMAIL PROTECTED]
Subject: MI-L DEBUG problem


Good Morning

I have written the following code to determine if a tablename is the result
of a query and if it is to 
remove it.
The code seems to work but after four or five loops it causes an error. I
have tried to use error handlers 
but cannot see the problem.
Can anybody offer any advice.

Thanks in advance
include "mapbasic.def"

Declare Sub Close_Query
Declare Sub Main

Sub Main

Call Close_Query

End Sub

Sub Close_Query

Dim sLaynum as smallint
Dim Total_Layers as Integer, I as Integer
Dim Prt_Name as String
Dim sLayname as String

Total_Layers = NumTables()

for I = 1 to Total_Layers

note I

sLayNum = tableInfo(i,TAB_INFO_NUM)
ONERROR GOTO SKIP
sLayName = tableInfo(sLayNum,TAB_INFO_NAME)

note sLayNum

Prt_Name = mid$(sLayname,1,5)

If Prt_Name = "Query" Then
Close Table slayname Interactive
End If




SKIP:
Next




End Sub



Daniel York
MapInfo Specialist
Information Team
Corporate Development
South Tyneside Council
Town Hall and Civic Offices
Westoe Road
South Shields
Tyne & Wear
NE33 2RL

0191 4247558



****************************************************************************
********************
Please do not print this e-mail if you can help it - and help protect the
environment.
****************************************************************************
********************
This Message may contain confidential information and is protected by
copyright. If you receive it in error please notify us and delete it without
making use of or copying it. The addressee and other employees within the
Council may read and copy any e-mail reply to this message and other e-mails
you send to us. Whilst we use virus checking procedures we accept no
liability for viruses and recipients 
must rely on their own virus checking procedures.
****************************************************************************
********************
The Council's web site address is www.southtyneside.info 

South Tyneside Business Week
7-13th July 2004, Bents Park, South Shields
www.southtyneside.info/businessweek

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com | To
unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12547




---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12560

Reply via email to