This is one of the nasty little surprises you'll get working with coordinate
systems in MapBasic:

THERE IS MORE THAN ONE "CURRENT COORDINATE SYSTEM"

Each MapBasic application has its own "current coordinate system".  So does
the MapBasic window.  But the MapBasic window is the environment in which
"Run Command" statements (and calls to "Mapinfo.do" for you integrated
mapping folks) are executed.  So, the "current coordinate system" for an
activity depends upon whether you're doing it with Run Command or not. 

Since you're executing something using Run Command that depends on the
current coordinate system, you have to set the current coordinate system
of the MapBasic window environment. You can do this with another Run Command
statement. Assuming that table1 is a string variable (I never hard-code
table names):


Run Command "Set coordsys table """+table1+""""
S = Select etc etc
Run command S

It's hard to keep track of this sometimes (and you usually have to do both
anyway), so I've written a module dedicated to setting and retrieving the
current coordinate system, and always use that.

HTH
Spencer


-----Original Message-----
From: Dowdall, Jamie J [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 20, 2004 6:18 AM
To: '[EMAIL PROTECTED]'
Subject: MI-L Coordsys Mapbasic Problem

Hi All

I have a mapbasic program that uses the distance function in a query to join
two tables and list the distances between the two sets of eastings and
northings.

I first wrote the code in Mapbasic window in mapinfo and pasted into
mapbasic,( in mapinfo) this did not work correctly (incorrect distance
values)at first until I set the coordsys of one of the tables before
executing the query again.

In the mapbasic window (in mapinfo)

I wrote the following two lines of code

Set coordsy table "table1"
Select table1.shopname,table2.shopname,
Distance(table1.x,table1.y,table2.x,table2.y,"Mi")where table1.link =
table2.link into selection
Browse * from selection

Upon running this in the mapbasic window (in mapinfo) line by line it worked
correctly

And a browser was produced with the distances correctly measured.

I pasted this code into Mapbasic and compiled without errors

I had to change the statement a little to run the sql

Set coordsys table "table"
S = Select etc etc
Run command S

But once run as a program, the results did not work from MapBasic.

The browser appears but the distance values are all zeros.

If then I go into Mapbasic window in mapinfo and write

Set coordsys table "table1"

And press enter an hour glass appears then the browser that was previously
open updates with the correct distances.

Why is exactly the same code not working in mapbasic but works in the
mapbasic window in mapinfo..

Hope somebody can please help. I feel like I am going round in circles

Thanks 
Jamie


This email and any attached files are confidential and copyright protected.
If you are not the addressee, any dissemination of this communication is
strictly prohibited. Unless otherwise expressly agreed in writing, nothing
stated in this communication shall be legally binding.



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



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

Reply via email to