Purpose
Returns a text object created for a specific map window. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
CreateText( window_id, x, y, text, angle, anchor, offset )
window_id is an integer window identifier that represents a Map window.
x, y are float values, representing the x/y location where the text is anchored.
text is a string value, representing the text that will comprise the text object.
angle is a float value, representing the angle of rotation; for horizontal text, specify zero.
anchor is an integer value from 0 to 8, controlling how the text is placed relative to the anchor location. Specify one of the following codes; codes are defined in MAPBASIC.DEF.
LAYER_INFO_LBL_POS_CC (0)
LAYER_INFO_LBL_POS_TL (1)
LAYER_INFO_LBL_POS_TC (2)
LAYER_INFO_LBL_POS_TR (3)
LAYER_INFO_LBL_POS_CL (4)
LAYER_INFO_LBL_POS_CR (5)
LAYER_INFO_LBL_POS_BL (6)
LAYER_INFO_LBL_POS_BC (7)
LAYER_INFO_LBL_POS_BR (8)
The two-letter suffix indicates the label orientation: T=Top, B=Bottom, C=Center, R=Right, L=Left. For example, to place the text below and to the right of the anchor location, specify the define code LAYER_INFO_LBL_POS_BR, or specify the value 8.
offset is an integer from zero to 200, representing the distance (in points) the text is offset from the anchor location; offset is ignored if anchor is zero (centered).
Return Value
Object
Description
The CreateText() function returns an Object value representing a text object.
The text object uses the current Font style. To create a text object with a specific Font style, issue the Set Style statement before calling CreateText().
At the moment the text is created, the text height is controlled by the current Font. However, after the text object is created, its height depends on the Map window's zoom; zooming in will make the text appear larger.
The object returned 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).
Example
The following example creates a text object and inserts it into the map's Cosmetic layer (given that the variable i_map_id is an integer containing a Map window's ID).
Insert Into Cosmetic1 (Obj)
Values ( CreateText(i_map_id, -80, 42.4, "Sales Map", 0,0,0) )
See Also:
AutoLabel statement, Create Text statement, Font clause, Insert statement, Update statement