Peter wrote:
> MapInfo supports MultiPoint objects which could do what you are
> searching for.
> Using the MapBasic window you might be able to do this:
> Update MYTABLE Set OBJ = Combine(CreatePoint(O_LONG, O_LAT),
CreatePoint(D_LONG, D_LAT))
I was about to send him a message about specifying the versions of MapInfo
that this will work in (6.5 or later) when I realized that this could be
done using a really early version of MapBasic (5.0, which I use
exclusively)!
If you have a recent version of MapInfo Professional and
an old MapBasic compiler, you have to access most new functionality using
Run Command statements. But Run Command is inconvenient when you need to
use an object variable, and you can do more things with object variables
now.
However, the basic syntax for most object variable operations already
existed in earlier versions of MapBasic.
For example, to use a Create Multipoint into variable statement, I'd
have to do something like this:
Run Command "dim O as object"
Run Command "Create Multipoint into variable O " etc...
Getting the object stored in the MapBasic window variable O is hellish
(insert it into a table using Run Command, then fetch the appropriate row
and get the object inline).
In the case of the thread that started all this, the combine() function
existed in MapInfo 5.0. You could combine regions into multi-part regions,
and polylines into multi-part polylines.
By MapInfo 6.5, combine() could also combine point objects into multipoint
objects.
When you compile a Combine() function in MapBasic, it inserts pseudocode
pointing to the combine() function, along with pseudocode to evaluate the
function's two arguments.
The pseudocode is run, however, in the environment of MapInfo Pro. If
an application compiled in MB 5 calls the combine() function with two point
objects when run in MI 6.5, it will create a multipoint object!
The code below does exactly what it's supposed to do (create a multipoint
object and put it into the cosmetic layer of a Map window). It does this
even when compiled in MapBasic 5.0.
Wow
Spencer
include "mapbasic.def"
declare function OpenAMappableTable (ByVal p as string, ByVal promt as
string) as string
declare sub main
sub main
dim t as string
dim xl as float
dim yl as float
dim xh as float
dim yh as float
dim dx as float
dim dy as float
dim m as integer
dim o as object
dim cl as string
t = OpenAMappableTable ("", "Select any mappable table:")
if t = ""
then exit sub
end if
set coordsys table t
map from t
m = FrontWindow()
xl = TableInfo (t, TAB_INFO_MINX)
yl = TableInfo (t, TAB_INFO_MINY)
xh = TableInfo (t, TAB_INFO_MAXX)
yh = TableInfo (t, TAB_INFO_MAXY)
dx = xh - xl
dy = yh - yl
xh = xl + 3/4 * dx
yh = yl + 3/4 * dy
xl = xl + 1/4 * dx
yl = yl + 1/4 * dy
o = Combine(CreatePoint (xl, yl), CreatePoint (xh, yh))
cl = LayerInfo (m, 0, LAYER_INFO_NAME)
insert into cl (obj) Values (o)
select * from cl where rowid = 1
end sub
'
' OpenAMappableTable: I've made this a function to abstract away the task
' of prompting for a table, which doesn't strictly apply
' to the topic
'
function OpenAMappableTable (ByVal p as string, ByVal promt as string) as
string
dim t as string
dim e as string
p = ""
do
p = FileOpenDlg (p, "*.TAB", "TAB", promt)
if p = ""
then OpenAMappableTable = ""
exit function
else OnError goto openerr
open table p
OnError goto 0
t = TableInfo (0, TAB_INFO_NAME)
if TableInfo (t, TAB_INFO_MAPPABLE)
then OpenAMappableTable = t
exit function
else e = t + " is not mappable."
end if
end if
tryagain:
note e
p = PathToDirectory$(p)
loop
openerr: e = error$()
e = p + chr$(13) + e
resume tryagain
end function
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 11903