turning mapbasic commands into a mapbasic program

170 views
Skip to first unread message

RobH

unread,
Apr 22, 2008, 6:33:02 AM4/22/08
to MapInfo-L
I am an inexperienced user of MapInfo/MapBasic, but use other
progrmaming languages such as VB.

Within MapInfo (v9.0) I have manually gone through a process of
opening an ASCII file as a table, creating points from the LAt/Long
columns, and adding the data as a layer on my base map. This works
fine, but when I paste the code generated in the MapBasic window into
a MapBasic program and try to run it, it does not work. It goes
thorugh all the stages fine, but does not display the points on the
map. The code generated is as follows:

Register Table "\\d\COIR\DEV-COIR_Non-op_beaches.txt" TYPE ASCII
Delimiter 9 Charset "WindowsLatin1" Into "\\d\COIR\DEV-COIR_Non-
op_beaches.TAB"
Open Table "\\d\COIR\DEV-COIR_Non-op_beaches.TAB" Interactive
Browse * From DEV_COIR_Non_op_beaches
Create Map For DEV_COIR_Non_op_beaches CoordSys Earth Projection 1, 0
set map redraw off
Add Map Layer DEV_COIR_Non_op_beaches
Set Map Layer 1 Display Global Zoom (0, 100000) Units "km" Off
Editable Off Selectable On Global Line (1,2,0) Global Pen (1,2,0)
Global Brush (2,16777215,16777215) Global Symbol (32,255,12) Global
Font ("Arial",0,9,0) Label Line Arrow Position Right Font ("Arial",
0,9,0) Pen (1,2,0) With _COL2 Parallel On Auto Off Overlap Off
PartialSegments Off Duplicates On Offset 2 Max Visibility On Nodes Off
Arrows Off Centroids Off
set map redraw on.

Any suggestions would be gratefully received.

Thanks,

Driver, Greg 9434

unread,
Apr 22, 2008, 6:51:22 AM4/22/08
to mapi...@googlegroups.com
You're missing one step in the process where the points are actually
created. You just need to enter the following lines between the Create
Map and Add Map statements:

set coordsys table DEV-COIR_Non-op_beaches
Update DEV-COIR_Non-op_beaches Set obj = (CreatePoint (col1, col2))

Where col1 and col2 = the column names that hold the lat/long
coordinates. The first line sets the coordinate system in MapBasic, so
the points are created using the correct projection. I don't think the
Update statement is included in the MapBasic window when you're running
through the process manually, so it wasn't copied over when you cut and
pasted.

HTH


Greg Driver

System Administrator
Applications Support
ICT
Surrey Police
NOT PROTECTIVELY MARKED

Thanks,


*Internet communications are not secure and therefore Surrey Police does not accept legal responsibility for the contents of this message. This email and any attachments may be confidential. They may contain privileged information and are intended for the named addressee (s) only. They must not be distributed without our consent. If you are not the intended recipient, please notify us immediately and delete the message and any attachments from your computer, do not disclose, distribute, or retain this email or any part of it. Unless expressly stated, opinions in this email are those of the individual sender, and not of Surrey Police. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking. Surrey Police reserves the right to monitor all email communications through their networks.*

RobH

unread,
Apr 22, 2008, 7:23:25 AM4/22/08
to MapInfo-L
Thanks Greg,

I have added the lines as you suggested, but now get the error
message:

(robtest3.mb:5)Numeric values required.

The amended code is below, Lat & Long come from columns 3 & 4.

Register Table "\\d\COIR\DEV-COIR_Non-op_beaches.txt" TYPE ASCII
Delimiter 9 Charset "WindowsLatin1" Into "\\d\COIR\DEV-COIR_Non-
op_beaches.TAB"
Open Table "\\d\COIR\DEV-COIR_Non-op_beaches.TAB" Interactive
Browse * From DEV_COIR_Non_op_beaches
Create Map For DEV_COIR_Non_op_beaches CoordSys Earth Projection 1, 0
Set Coordsys table DEV-COIR_Non-op_beaches
Update DEV-COIR_Non-op_beaches Set obj = (CreatePoint(col4,col3))
set map redraw off
Add Map Layer DEV_COIR_Non_op_beaches
Set Map Layer 1 Display Global Zoom (0, 100000) Units "km" Off
Editable Off Selectable On Global Line (1,2,0) Global Pen (1,2,0)
Global Brush (2,16777215,16777215) Global Symbol (32,255,12) Global
Font ("Arial",0,9,0) Label Line Arrow Position Right Font ("Arial",
0,9,0) Pen (1,2,0) With _COL2 Parallel On Auto Off Overlap Off
PartialSegments Off Duplicates On Offset 2 Max Visibility On Nodes Off
Arrows Off Centroids Off
set map redraw on

Your assistance is much appreciated...

Thanks,
Rob

On Apr 22, 11:51 am, "Driver, Greg 9434"
> *Internet communications are not secure and therefore Surrey Police does not accept legal responsibility for the contents of this message. This email and any attachments may be confidential. They may contain privileged information and are intended for the named addressee (s) only. They must not be distributed without our consent. If you are not the intended recipient, please notify us immediately and delete the message and any attachments from your computer, do not disclose, distribute, or retain this email or any part of it. Unless expressly stated, opinions in this email are those of the individual sender, and not of Surrey Police. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking. Surrey Police reserves the right to monitor all email communications through their networks.*- Hide quoted text -
>
> - Show quoted text -

Uffe Kousgaard

unread,
Apr 22, 2008, 7:32:10 AM4/22/08
to mapi...@googlegroups.com
Try

Update DEV-COIR_Non-op_beaches Set obj = CreatePoint(_col4,_col3)

If that doesn't work, check out the actual column names.

Also, is the table name correct? Having a minus in the name could be an
issue. MapInfo sometimes changes certain table names when opening them, so
the filename doesn't match the name you have to use inside mapinfo/mapbasic.

Regards
Uffe Kousgaard

RobH

unread,
Apr 22, 2008, 7:40:20 AM4/22/08
to MapInfo-L
Thanks Uffe,

Changing the minuses for underscores worked, the program now works
perfectly!

Thanks to you and Greg for your help...

Rob
> > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages