CreateLine() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns an Object value representing a line. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

CreateLine( x1, y1, x2, y2 ) 

x1 is a float value, indicating the x-position (for example,) of the line's starting point.

y1 is a float value, indicating the y-position (for example, Latitude) of the line's starting point.

x2 is a float value, indicating the x-position of the line's ending point.

y2 is a float value, indicating the y-position of the line's ending point.

Return Value

Object

Description

The CreateLine() function returns an Object value representing a line. The x and y parameters use the current coordinate system. By default, MapBasic uses a Longitude/Latitude coordinate system. Use the Set CoordSys statement to choose a new system.

The line object will use whatever Pen style is currently selected. To create a line object with a specific Pen style, you could issue the Set Style statement before calling CreateLine() or you could issue a Create Line statement, with an optional Pen clause.

The line object created through the CreateLine() function could be assigned to an Object variable, stored in an existing row of a table (through the Update statement), or inserted into a new row of a table (through an Insert statement). If you need to create objects on a Layout window, you must first issue a Set CoordSys Layout statement.

Example

The following example uses the Insert statement to insert a new row into the table Routes. The CreateLine() function is used within the body of the Insert statement.

Open Table "Routes" 
Insert Into routes (obj) 
	Values (CreateLine(-72.55, 42.431, -72.568, 42.435))

See Also:

Create Line statement, Insert statement, Update statement