And it's *still* not that simple. If you don't know the coordinate system ahead of time (i.e. you don't want to hard-code it into the program), you have to use Run Command to set the current coordinate system to a string. And then you run into a little problem with the application's "current coordinate system" not being the same as the MapBasic window's "current coordinate system" (which Run Command sets).
I eventually got to the point where I had to write a module for getting/setting the current coordinate system, using a temporary table. Hope this helps Spencer -----Original Message----- From: Peter Zyczynski [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 04, 2005 1:21 AM To: 'MapInfo-L' Subject: RE: MI-L MB - Show clicked location in multiple coordinate systems? >From subsequent testing, it appears you have to set Mapbasic's coordsys clause *BEFORE* making a call to CommandInfo(CMD_INFO_X) , CommandInfo(CMD_INFO_X). Which of course is no good in my situation. Fortunately CentroidX and CentroidY doesn't have that limitation. So the solution is to create a point feature into an object varaible and call CentroidX, CentroidY on it just after setting Mapbasic's coordsys clause. Sub ShowPositionInfoA ' Show the clicked position in various coordinate systems. ' 1. Lat/Long ' 2. GDA94 ' 3. AGD66 dim xLL, yLL, xGDA, yGDA, xAGD, yAGD as float, o as object ' Create a point object into a variable, using clicked location for X,Y. o = createPoint(CommandInfo(CMD_INFO_X), CommandInfo(CMD_INFO_Y)) ' Get coords in Lat/Long set coordSys Earth Projection 1, 104 xLL = CentroidX(o) yLL = CentroidY(o) ' Get coords in Easting/Northing GDA94 set coordSys Earth Projection 8, 33, "m", 147, 0, 0.9996, 500000, 10000000 Bounds (-7745844.29605, 2035.05684549) (8745844.29605, 19997964.9432) xGDA = CentroidX(o) yGDA = CentroidY(o) ' Get coords in Easting/Northing AGD66 set coordSys Earth Projection 8, 12, "m", 147, 0, 0.9996, 500000, 10000000 Bounds (-7745874.38492, 1999.40969607) (8745874.38492, 19998000.5903) xAGD = CentroidX(o) yAGD = CentroidY(o) Note "Lat/Long = " + xLL + " , " + yLL + CR + "GDA94 = " + xGDA + " , " + yGDA + CR + "AGD66 = " + xAGD + " , " + yAGD End Sub -----Original Message----- From: Peter Zyczynski [mailto:[EMAIL PROTECTED] Sent: Tuesday, 4 October 2005 3:32 PM To: 'MapInfo-L' Subject: MI-L MB - Show clicked location in multiple coordinate systems? Hi All, I have custom toolbutton that displayes the position of where the user clicked on the map. It's supposed to display the position in three different coordinate systems. The following code always displays lat/long no matter what I set the coordsys to. Any ideas why? Sub ShowPositionInfo ' Show the clicked position in various coordinate systems. ' 1. Lat/Long ' 2. GDA94 ' 3. AGD66 dim xLL, yLL, xGDA, yGDA, xAGD, yAGD as float ' Get coords in Lat/Long set coordSys Earth Projection 1, 104 xLL = CommandInfo(CMD_INFO_X) yLL = CommandInfo(CMD_INFO_Y) ' Get coords in Easting/Northing GDA94 set coordSys Earth Projection 8, 33, "m", 147, 0, 0.9996, 500000, 10000000 Bounds (-7745844.29605, 2035.05684549) (8745844.29605, 19997964.9432) xGDA = CommandInfo(CMD_INFO_X) yGDA = CommandInfo(CMD_INFO_Y) ' Get coords in Easting/Northing AGD66 set coordSys Earth Projection 8, 12, "m", 147, 0, 0.9996, 500000, 10000000 Bounds (-7745874.38492, 1999.40969607) (8745874.38492, 19998000.5903) xAGD = CommandInfo(CMD_INFO_X) yAGD = CommandInfo(CMD_INFO_Y) Note = "Lat/Long = " + xLL + " , " + yLL + CR + "GDA94 = " + xGDA + " , " + yGDA + CR + "AGD66 = " + xAGD + " , " + yAGD End Sub Thanks, Peter --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 18114 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 18115 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 18125
