Create Text statement - 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

Creates a text object (such as a title), for a Map window, Layout window, or classic Layout window. Not all clauses are supported with a Layout window, see Description for details. You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Create Text 
	[ Into { Window window_id | Variable var_name } ] 
	 text_string 
	( x1, y1 ) ( x2, y2 ) 
	[ Font... ] 
	[ Label Line { Simple | Arrow } ( label_x, label_y ) Pen (pen_expr) ] 
	[ Spacing { 1.0 | 1.5 | 2.0 } ] 
	[ Justify { Left | Center | Right } ] 
	[ Angle text_angle ]
	[ Pen .... ] [ Brush ... ] [ Priority n ] [ Name framename ]

window_id is an integer window identifier.

var_name is the name of an existing object variable.

text_string specifies the string, up to 2047 characters long, that will constitute the text object; to create a multiple-line text object, embed the function call Chr$(10) in the string.

x1, y1 are floating-point coordinates, specifying one corner of the rectangular area which the text will fill.

x2, y2 specifies the opposite corner of the rectangular area which the text will fill. This coordinate is still necessary when creating text in a Map window, but is optional when creating text in a Layout Designer window.

The Font clause specifies a text style. The point-size element of the Font is ignored if the text object is created in a Map window; see below.

label_x, label_y specifies the position where the text object's label line is anchored.

Pen specifies the pen clause settings of callouts created in the classic Layout window (not in a Layout window).

text_angle is a float value indicating the angle of rotation for the text object (in degrees).

n is an integer value indicating the Z-Order value of objects (frames) on the Layout window. When creating a clone statement or saving a workspace, MapInfo Pro normalizes the priority of frames to a unique set of values beginning with 1.

framename is a string representing the name for this text frame in a layout designer. If a name is assigned to a frame in the Layout window, it will be written to the WOR. When the Name clause is written to the WOR, the workspace version is updated to version 1500.

Description

Not all clauses work with a Layout window: the Label Line clause is ignored. You can only use the pen clause to persist the new label line styles in classic layouts in a Layout window.

The window_id parameter specifies which window to query. To obtain a window identifier, call the FrontWindow() function immediately after opening a window, or call the WindowID() function at any time after the window's creation.

The x and y parameters use whatever coordinate system MapBasic is currently using. By default, MapBasic uses a Longitude/Latitude coordinate system, although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. If you need to create objects on a layout (in a Layout window or a classic Layout window), you must first issue a Set CoordSys Layout statement.

The x1, y1, x2, and y2 arguments define a rectangular area. When you create text in a Map window, the text fills the rectangular area, which controls the text height; the point size specified in the Font clause is ignored. On a Layout Designer, the (x2, y2) coordinate is optional. When it is not included, the text frame created will be sized to fit the extents of the text based on the Font currently being applied. When the (x2, y2) coordinate is included, the text frame is sized based on the dimensions given by both coordinates. The text may wrap if the size of the frame is too small, or may have extra space if the size of the frame specified is larger than the extents of the text string.

Brush is a valid Brush clause. Only Solid brushes are allowed. While values other than solid are allowed as input without error, the type is always forced to solid. This clause is used only to provide the background color for the frame.

Pen is a valid Pen clause. This clause is designed to turn on (solid) or off (hollow) and set the color of the border of the frame.

Example

When the user creates a label line in a classic Layout window, the Create Text Label Line Pen clause is invoked and the workspace version is incremented to 950:

!Workspace
!Version 950
!Charset WindowsLatin1
Open Table "Data\Introductory_Data\World\WORLD" As WORLD Interactive
Map From WORLD 
  Position (0.0520833,0.0520833) Units "in"
  Width 6.625 Units "in" Height 4.34375 Units "in"
Set Window FrontWindow()
Set Map
  CoordSys Earth Projection 1, 104
  Center (35.204159,-25.3575215)
  Zoom 18063.92971 Units "mi"
  Preserve Zoom Display Zoom
  Distance Units "mi" Area Units "sq mi" XY Units "degree"
Set Map
  Layer 1
	Display Graphic
	Global Pen (1,2,0)  Brush (2,16777215,16777215)  Symbol (35,0,12)  
Line (1,2,0)  Font ("Arial",0,9,0)
	Label Line None Position Center Font ("Arial",0,9,0) Pen (1,2,0)

See Also:

FrontWindow() function, AutoLabel statement, CreateText() function, Font clause, Insert statement, Update statement, WindowID() function