Hi Mike,

Repeated identical calls to CommandInfo is definitely discouraged, as the return 
values may change during statement executions. Always use variables to pick up the 
values at the earliest possible moment.

And always set the coordinate system prior to getting or setting coordinate values in 
any routine.

That fixed, the code seems valid enough. Only possible problem left if it stills 
doesn't work, is using the antiquated "ToolHandler" over a custom routine called from 
a custom toolbutton. There might be some limitations wrt. ToolHandler, so I'll suggest 
you move your code (no changes required) to a custom setup. Creating custom buttonpads 
and adding custom buttons to existing buttonpads is very easy to do.

Best regards / Med venlig hilsen
Lars V. Nielsen
Odense, Denmark
----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 28, 2002 1:47 AM
Subject: MI-L Distance() problem in ToolHandler


> I am having trouble getting ToolHandler to calculate distances. 
> 
> I have a map of table PointsA containing points.  This code executes when the 
> MapBasic tool is clicked on the map.
> The CMD_INFO_X and CMD_INFO_Y appear properly in Print and Note statements, 
> but the Select statement treats them as if they are 0.
> I have tried putting them into variables, with the same result.    I have 
> tried Set Coordsys to match the map, same.
> 
> Using MapInfo Pro v.7.0.
> 
> Thanks,
> Mike
> 
> 
> ''''''''''''''''''''''''''''''''''''
> Include "mapbasic.def" 
> Declare Sub ToolHandler
> Note "Ready to test the MapBasic tool." 
> Sub ToolHandler 
>     'this works
>     Note "x:" + Round(CommandInfo(CMD_INFO_X), 0.1) + Chr$(10) +
>          " y:" + Round(CommandInfo(CMD_INFO_Y), 0.1) 
> 
>     'this works
>     Note "Distance to L.A.: " +
>              Distance(CommandInfo(CMD_INFO_X),CommandInfo(CMD_INFO_Y),
>             -118.5 , 34.5, "mi")
> 
>     'this does not work
>     Select Distance(CommandInfo(CMD_INFO_X),CommandInfo(CMD_INFO_Y) ,
>             Centroidx(obj), Centroidy(obj), "mi") "Miles" 
>             From PointsA
>             Order By COL1 
>             Into Test0
>     Browse * From Test0
> 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: 3297
> 
> 


Reply via email to