I'm trying to create pline using MapBasic. My idea was to create simple tool with dialog box containing couple of EditBox, PopupMenu's to retrieve pline attributes from user. So far I have only making tools with same logic for point object and my code would look something like:
'************************************************************
Sub Main()
Create ButtonPad AppName
As toolbutton
Icon 16
DrawMode DM_CUSTOM_POINT
Cursor MI_CURSOR_LRG_CROSSHAIR
Calling SomePointSUB
Show
Fixed
End Sub
Sub SomePointSUB
click_x = CommandInfo(CMD_INFO_X)
click_y = CommandInfo(CMD_INFO_Y)
Insert Into "POINT_TAB" ("attribute1", "attribute2"...., obj)
values ((value1), (value2)....., CreatePoint(click_x, click_y))
End Sub
'************************************************************
So, this was straight forward, but creating polyline is not so (at least for me). All of the examples I found online had fixed number of nodes, like this (from MapBasic user guide):
'************************************************************
Include "mapbasic.def"
Type Point
x As Float
y As Float
End Type
Dim objcoord(5) As Point
Dim numnodes, i As Integer, myobj As Object
numnodes = 3
set CoordSys Earth
objcoord(1).x = -89.213 objcoord(1).y = 32.017
objcoord(2).x = -89.204 objcoord(2).y = 32.112
objcoord(3).x = -89.187 objcoord(3).y = 32.096
Create Pline Into Variable myobj 0
For i = 1 to numnodes
Alter Object myobj Node Add (objcoord(i).x,objcoord(i).y)
Next
Insert Into cables (obj) Values (myobj)
'************************************************************
MapBasic Reference says: "The Create Pline statement creates a polyline object. If you need to create a polyline object, but do not know until run-time how many nodes the object should contain, create the object in two steps: First, use Create Pline to create an object with no nodes, and then use the Alter Object statement to add detail to the polyline object."
I'm quite new to MapBasic, so I do understand logic of this (probably some loop will be required to add node for every click), but is simply out of my current MapBasic knowledge.