Map Basic Reference
Map Basic Reference
Version 15.2
Reference
Notices
Copyright
Information in this document is subject to change without notice and does not represent a commitment
on the part of the vendor or its representatives. No part of this document may be reproduced or
transmitted in any form or by any means, electronic or mechanical, including photocopying, without
the written permission of Pitney Bowes Software Inc., One Global View, Troy, New York 12180-8399.
© 2015 Pitney Bowes Software Inc. All rights reserved. Pitney Bowes Software Inc. is a wholly owned
subsidiary of Pitney Bowes Inc. Pitney Bowes, the Corporate logo, MapInfo, Group 1 Software, and
MapBasic are trademarks of Pitney Bowes Software Inc. All other marks and trademarks are property
of their respective holders.
Contact information for all Pitney Bowes Software Inc. offices is located at:
http://www.pitneybowes.com/us/contact-us.html.
© 2015 Adobe Systems Incorporated. All rights reserved. Adobe, the Adobe logo, Acrobat and the
Adobe PDF logo are either registered trademarks or trademarks of Adobe Systems Incorporated in
the United States and/or other countries.
© 2015 OpenStreetMap contributors, CC-BY-SA; see OpenStreetMap
http://www.openstreetmap.org (license available at www.opendatacommons.org/licenses/odbl)
and CC-BY-SA http://creativecommons.org/licenses/by-sa/2.0
libtiff © 1988-1997 Sam Leffler, © 2015 Silicon Graphics Inc. All Rights Reserved.
libgeotiff © 2015 Niles D. Ritter.
Amigo, Portions © 1999 Three D Graphics, Inc. All Rights Reserved.
Halo Image Library © 1993 Media Cybernetics Inc. All Rights Reserved.
Portions thereof LEAD Technologies, Inc. © 1991-2015. All Rights Reserved.
Portions © 1993-2015 Ken Martin, Will Schroeder, Bill Lorensen. All Rights Reserved.
ECW by ERDAS © 1993-2015 Intergraph Corporation, part of Hexagon Group and/or its suppliers.
All rights reserved.
Portions © 2015 Intergraph Corporation, part of Hexagon Group All Rights Reserved.
MrSID, MrSID Decompressor and the MrSID logo are trademarks of LizardTech, A Celartem
Company. used under license. Portions of this computer program are copyright © 1995-1998
LizardTech, A Celartem Company, and/or the university of California or are protected by US patent
no. 5,710,835 and are used under license. All rights reserved. MrSID is protected under US and
international patent & copyright treaties and foreign patent applications are pending. Unauthorized
use or duplication prohibited.
Contains FME® Objects © 2005-2015 Safe Software Inc., All Rights Reserved.
Amyuni PDF Converter © 2000-2015, AMYUNI Consultants – AMYUNI Technologies. All rights
reserved.
Civic England - Public Sector Symbols Copyright © 2015 West London Alliance. The symbols may
be used free of charge. For more information on these symbols, including how to obtain them for
use in other applications, please visit the West London Alliance Web site at
http://www.westlondonalliance.org
© 2006-2015 TomTom International BV. All Rights Reserved. This material is proprietary and the
subject of copyright protection and other intellectual property rights owned or licensed to TomTom.
The use of this material is subject to the terms of a license agreement. You will be held liable for
any unauthorized copying or disclosure of this material.
Microsoft Bing: All contents of the Bing service are Copyright © 2015 Microsoft Corporation and/or
its suppliers, One Microsoft Way, Redmond, WA 98052, USA. All rights reserved. Microsoft or its
suppliers own the title, copyright, and other intellectual property rights in the Bing service and content.
Microsoft, Windows, Windows Live, Windows logo, MSN, MSN logo (butterfly), Bing, and other
Microsoft products and services may also be either trademarks or registered trademarks of Microsoft
in the United States and/or other countries.
This product contains 7-Zip, which is licensed under GNU Lesser General Public License, Version
3, 29 June 2007 with the unRAR restriction. The license can be downloaded from
http://www.7-zip.org/license.txt. The GNU License may be downloaded from
http://www.gnu.org/licenses/lgpl.html. The source code is available from http://www.7-zip.org.
Products named herein may be trademarks of their respective manufacturers and are hereby
recognized. Trademarked names are used editorially, to the benefit of the trademark owner, with
no intent to infringe on the trademark.
In this section
Type Conventions 8
Language Overview 9
MapBasic Fundamentals 9
MapBasic IDE Features 11
Functions 13
Working With Tables 16
Working With Files (Other Than Tables) 19
Working With Maps and Graphical Objects 20
Creating the User Interface 25
Communicating With Other Applications 28
Special Statements and Functions 29
Getting Technical Support 30
Copyright 32
OpenSource Attribution Notices 33
Introduction to MapBasic
Type Conventions
This manual uses the following conventions to designate specific items in the text:
Convention Meaning
Main, Pen, Object Non-bold words with the first letter capitalized are usually
special procedure names or variable types.
Language Overview
The following pages provide an overview of the MapBasic language. Task descriptions appear on
the left; corresponding statement names and function names appear on the right, in bold. Function
names are followed by parentheses ().
MapBasic Fundamentals
Variables
LargeInt variables are supported in MapBasic, but they are not a fully supported type in a table,
because some operations may not work correctly for large values (such as thematic maps). Some
mathematic calculations or functions generate a LargeInt value. If the value is outside the range for
an Integer variable and your application tries to store the result in an Integer, you will get an overflow
error.
The following functions return a LargeInt value:
• Seek statement on page 654Seek statement
• LOF() function on page 476LOF() function
• Server_GetODBCHConn() function on page 695Server_GetODBCHConn() function
• Server_GetODBCHStmt() function on page 696Server_GetODBCHStmt() function
The following statements accept a LargeInt value for the file position:
• Seek statement
• Get statement
The following function return a IntPtr value when the specified attributes are requested.
• SystemInfo() function attributes SYS_INFO_APPLICATIONWND, SYS_INFO_MAPINFOWND,
SYS_INFO_MDICLIENTWND, and SYS_INFO_APPIDISPATCH.
• WindowInfo() function attribute WIN_INFO_WND.
IntPtr is a platform specific type that is used to represent a pointer or a handle. This helps to write
applications that will work with both the 32-bit and 64-bit versions of MapInfo Pro. The 64-bit version
of MapInfo Pro treats this like a LargeInt, and the 32-bit version of MapInfo Pro treats this like an
Integer.
Error Handling
MapBasic folder. The environment variables are called MBINCLUDE and MBMODULE for Include
and Module files, respectively, and their values should be set to a semi-colon delimited list of folders
to search. MapBasic will search the folders specified and all sub-folders beneath them.
You can set environment variables via the Advanced System Settings on your system. The
variables must be set before you run MapBasic for them to be effective.
To set additional search folders for Include files, set the environment variable MBINCLUDE. For
example, if you have libraries of .def files in or beneath the folders C:\My MapBasic Library
and C:\Work, set the MBINCLUDE environment variable as follows:
Do not use quotes around the folder names even if the path contains spaces.
To set additional search folders for Module files, similarly set the environment variable MBMODULE.
For example, if you have libraries of .mbo files in or beneath the folder C:\My MapBasic Library,
set the MBMODULE environment variable as follows:
Include “mapbasic.def”
Include “utilities.def”
Include “myapplication.def”
Assuming you set your environment variables as above, when compiling MapBasic will search for
these .def files first in the folder where the file your are compiling is located, then under C:\My
MapBasic Library and its subfolders, next under C:\Work and its subfolders, and last under
the folder where MapBasic was installed. If the file utilities.def, for example, is used by multiple
applications you’ve written you can put it somewhere under C:\My MapBasic Library or C:\Work
and MapBasic can find it without you having to specify the path in the code.
[Link]Application=myapplication.mbx
Module=myapplication.mbo
Module=library.mbo
If the file library.mbo, for example, is used by multiple applications you’ve written you can put it
somewhere under C:\My MapBasic Library and MapBasic can find it without you having to
specify the path in the project file.
Functions
Custom Functions
Data-Conversion Functions
Create a DateTime value from two individual Date and Time MakeDateTime()
values:
Sets and gets the rule for two-digit year input: Set Date Window(), DateWindow()
Math Functions
String Functions
Modify a table's structure: Alter Table, Add Column, Create Index, Drop Index,
Create Map, Drop Map
Querying Tables
File Input/Output
Creation statements: Create Arc, Create Ellipse, Create Frame, Create Line,
Create Object, Create PLine, Create Point, Create Rect,
Create Region, Create RoundRect, Create Text,
AutoLabel, Create Multipoint, Create Collection
Configure units of measure: Set Area Units, Set Distance Units, Set Paper Units,
UnitAbbr$(), UnitName$()
Processing Objects
Use concurrency when processing these objects: Create Object as Buffer, Objects Erase, Objects
Intersect, Objects Overlay
Style clauses: Pen clause, Brush clause, Symbol clause, Font clause
Show all selected objects in a layer: Changing the Current View of the Map
Create or modify thematic layers: Shade, Set Shade, Create Ranges, Create Styles, Create
Grid, Relief Shade
Set the focus to a Layout window or bring it to the front: Set Window, Run Menu Command
Add a map, a table (Browser), a map legend, an image, and Map, Browse, Create Designer Legend, Add Image
text to the layout: Frame, Create Text
Add a shape to the layout: Create Line, Create Ellipse, Create Rect, Create
RoundRect
Modify a layout or bring a frame to the front: Set Layout, Run Menu Command
Set the focus to a Layout window or bring it to the front: Set Window, Run Menu Command
Create, modify, and remove a legend frame: Add Designer Frame, Alter Designer Frame, Remove
Designer Frame
Create map legend and thematic map legend: Create Cartographic Legend, Create Legend
Create, modify, and remove a legend frame: Add Cartographic Frame, Alter Cartographic Frame,
Remove Cartographic Frame
This version of MapBasic is compatible with both 32-bit and 64-bit versions of MapInfo® Pro. All
user interface modification MapBasic commands work the same way as before with the 32-bit version
of MapInfo Pro.
For MapInfo Pro 64-bit, as it uses the new Ribbon Interface instead of menus, MapBasic commands
related to ButtonPads and Menus create a new tab called LEGACY in the MapInfo Pro ribbon and
any modifications using these commands are visible only on this tab.
ButtonPads (ToolBars)
The 64-bit version of MapInfo Pro supports all the listed ButtonPads related MapBasic commands
except ButtonPadInfo().
Menus
In the 64-bit version of MapInfo Pro, the MenuItemInfoByHandler() and MenuItemInfoByID()
commands listed below are only supported for addin controls, not for MapInfo Pro default controls.
Dialog Boxes
Windows
Open a new window: Map, Browse, Graph, Layout, Create Redistricter, Create
Legend, Create Cartographic Legend, LegendFrameInfo
Modify an existing window: Set Map, Shade, Add Map, Remove Map, Set Browse,
Set Graph, Set Layout, Create Frame, Set Legend, Set
Cartographic Legend, Set Redistricter, StatusBar, Alter
Cartographic Frame, Add Cartographic Frame, Remove
Cartographic Frame
Integrated Mapping
Switch between 1-bit per pixel cursors and 32-bit per pixel Set Cursor
cursors:
Pitney Bowes Inc. offers a free support period on all new software purchases and upgrades, so you
can be productive from the start. Once the free period ends, Pitney Bowes Inc. offers a broad
selection of extended support services for individual, business, and corporate users.
Technical Support is here to help you, and your call is important. This section lists the information
you need to provide when you call your local support center. It also explains some of the technical
support procedures so that you will know what to expect about the handling and resolution of your
particular issue.
Please remember to include your serial number, partner number or contract number when contacting
Technical Support.
Software Defects
If the issue is deemed to be a bug in the software, the representative will log the issue in Pitney
Bowes Inc. bug database and provide you with an incident number that you can use to track the
bug. Future upgrades and patches have fixes for many of the bugs logged against the product.
Other Resources
MapInfo-L Archive Database
Pitney Bowes Inc. Corporation, in conjunction with Bill Thoen, provides a web-based, searchable
archive database of MapInfo-L postings. The postings are currently organized by Discussion Threads
and Postings by Date.
Disclaimer: While Pitney Bowes Inc. Corporation provides this database as a service to its user
community, administration of the MapInfo-L mailing list is still provided by Bill Thoen. More information
on MapInfo-L can be obtained at the MapInfo-L web page located at
http://groups.google.com/group/mapinfo-l?hl=en.
Copyright
Information in this document is subject to change without notice and does not represent a commitment
on the part of the vendor or its representatives. No part of this document may be reproduced or
transmitted in any form or by any means, electronic or mechanical, including photocopying, without
the written permission of Pitney Bowes Software Inc., One Global View, Troy, New York 12180-8399.
© 2015 Pitney Bowes Software Inc. All rights reserved. Pitney Bowes Software Inc. is a wholly owned
subsidiary of Pitney Bowes Inc. Pitney Bowes, the Corporate logo, MapInfo, Group 1 Software, and
MapBasic are trademarks of Pitney Bowes Software Inc. All other marks and trademarks are property
of their respective holders.
Contact information for all Pitney Bowes Software Inc. offices is located at:
http://www.pitneybowes.com/us/contact-us.html.
© 2015 Adobe Systems Incorporated. All rights reserved. Adobe, the Adobe logo, Acrobat and the
Adobe PDF logo are either registered trademarks or trademarks of Adobe Systems Incorporated in
the United States and/or other countries.
© 2015 OpenStreetMap contributors, CC-BY-SA; see OpenStreetMap
http://www.openstreetmap.org (license available at www.opendatacommons.org/licenses/odbl)
and CC-BY-SA http://creativecommons.org/licenses/by-sa/2.0
libtiff © 1988-1997 Sam Leffler, © 2015 Silicon Graphics Inc. All Rights Reserved.
libgeotiff © 2015 Niles D. Ritter.
Amigo, Portions © 1999 Three D Graphics, Inc. All Rights Reserved.
Halo Image Library © 1993 Media Cybernetics Inc. All Rights Reserved.
Portions thereof LEAD Technologies, Inc. © 1991-2015. All Rights Reserved.
Portions © 1993-2015 Ken Martin, Will Schroeder, Bill Lorensen. All Rights Reserved.
ECW by ERDAS © 1993-2015 Intergraph Corporation, part of Hexagon Group and/or its suppliers.
All rights reserved.
Portions © 2015 Intergraph Corporation, part of Hexagon Group All Rights Reserved.
MrSID, MrSID Decompressor and the MrSID logo are trademarks of LizardTech, A Celartem
Company. used under license. Portions of this computer program are copyright © 1995-1998
LizardTech, A Celartem Company, and/or the university of California or are protected by US patent
no. 5,710,835 and are used under license. All rights reserved. MrSID is protected under US and
international patent & copyright treaties and foreign patent applications are pending. Unauthorized
use or duplication prohibited.
Contains FME® Objects © 2005-2015 Safe Software Inc., All Rights Reserved.
Amyuni PDF Converter © 2000-2015, AMYUNI Consultants – AMYUNI Technologies. All rights
reserved.
Civic England - Public Sector Symbols Copyright © 2015 West London Alliance. The symbols may
be used free of charge. For more information on these symbols, including how to obtain them for
use in other applications, please visit the West London Alliance Web site at
http://www.westlondonalliance.org
© 2006-2015 TomTom International BV. All Rights Reserved. This material is proprietary and the
subject of copyright protection and other intellectual property rights owned or licensed to TomTom.
The use of this material is subject to the terms of a license agreement. You will be held liable for
any unauthorized copying or disclosure of this material.
Microsoft Bing: All contents of the Bing service are Copyright © 2015 Microsoft Corporation and/or
its suppliers, One Microsoft Way, Redmond, WA 98052, USA. All rights reserved. Microsoft or its
suppliers own the title, copyright, and other intellectual property rights in the Bing service and content.
Microsoft, Windows, Windows Live, Windows logo, MSN, MSN logo (butterfly), Bing, and other
Microsoft products and services may also be either trademarks or registered trademarks of Microsoft
in the United States and/or other countries.
This product contains 7-Zip, which is licensed under GNU Lesser General Public License, Version
3, 29 June 2007 with the unRAR restriction. The license can be downloaded from
http://www.7-zip.org/license.txt. The GNU License may be downloaded from
http://www.gnu.org/licenses/lgpl.html. The source code is available from http://www.7-zip.org.
Products named herein may be trademarks of their respective manufacturers and are hereby
recognized. Trademarked names are used editorially, to the benefit of the trademark owner, with
no intent to infringe on the trademark.
QT Assistant 5.2.0
This product contains QT Assistant, version 5.2.0, which is licensed under GNU Lesser General
Public License, Version 2.1, February 1999. The license can be downloaded from:
http://www.gnu.org/licenses/lgpl-2.1.txt. The source code for this software is available from
http://qt-project.org/downloads.
In this section
New MapBasic Functions and Statements 35
Updates to Existing Functions and Statements 35
New and Enhanced MapBasic Statements and Functions
Dim statement - Now declares three more variables: IntPtr to represent a pointer or a handle,
and This and RefPtr to reference a .NET object.
FileOpenDlg() function - Added the following to the list of file types that will appear in the File
Open dialog box:
Run Menu Command statement - Added a section about accessing the Layout Window menu
options.
Set Table statement - A new InUse clause specifies what sort of access (ReadAccess or
WriteAccess) is available to a table when it is in use.
TableInfo() function - This function has new attributes. For information on how to set a table as in
use, see the Set Table statement.
TAB_INFO_DATA_FORMAT 47 SmallInt result: indicates the data format of the base table
(which is not a WMF, WFS, raster, FME, or query). The
return values are:
TAB_INFO_MAP_BLOCKSIZE 49 SmallInt result: the block size of the map file. If table is
not mappable, returns -1. (A table without a .map file
returns -1.)
TAB_INFO_READVERSION 50 Integer result: earliest version that can read the table.
TAB_INFO_EDITVERSION 51 Integer result: earliest version that can edit the table.
TAB_INFO_READALLVERSION 52 Integer result: earliest version that can read the entire
table.
The following statements now include a Priority clause to assign the Z-Order of the newly created
object frame on the Layout window, and a Name clause to assign a name to the frame:
• Create Ellipse statement
• Create Line statement
• Create Pline statement
• Create Point statement
• Create Rect statement
• Create Region statement
• Create RoundRect statement
Open Connection statement - New subclause, Servicename added to support new geocoding
services.
Geocode statement - New clause, PassThrough added that represents a set of name/value pairs
that are sent to the geocoder.
New Layout Window Enhancements
Create Text statement - Now supports the Angle clause for Layout windows.
LayerInfo() function - Has new attributes:
LAYER_INFO_LABEL_POS_RETRY 74 Logical value, TRUE if the label property for Try other
positions is set and FALSE otherwise.
LAYOUT_ITEM_INFO_ANGLE 18 Float value: Returns the angle of rotation for a text frame
(in degrees)
Set Layout statement - Now includes a Page clause to set the current page in a multi-page Layout
window.
Set Map statement - Has a new section, Set Map Layer Gridline, that describes how to work with
gridlines.
Support For Working in Multiple Languages
Asc() function and Chr$ function - In Unicode versions of MapInfo Pro, these functions operate
in the system character set in a compatible manner with the non-Unicode versions of MapInfo Pro.
CharSet clause - Now supports "Utf-8" for a workspace character set or Native Extended format
table character set and to allow characters from any language to be represented. It can also be
used when importing, opening or registering a non-native table. This clause also supports "UTF-16"
for a Native Extended format table character set.
MidByte$() function - On systems with single-byte character sets, or in Unicode versions of MapInfo
Pro, the results returned by the MidByte$() function are identical to the results returned by the
Mid$() function.
Register Table statement - Now supports Unicode character sets for XLS, ODBC, Raster, and
Shape files. Also, the persistent cache type for shape files and cache for ODBC files can be set to
MapInfo (Native) or MapInfo Extended (NativeX) Tab file formats.
Save Workspace statement - Includes the new CharSet clause to specify a character set. It's
char_set parameter should be a string constant, such as "WindowsLatin1". If no CharSet clause is
specified, MapBasic uses the system character set that is in use at runtime. Specifying "UTF-8" as
the workspace character set allows characters from any language to be represented.
SystemInfo() function - Has new attributes.
• Insert statement (when set to Off or Auto, behavior varies slightly from other statements)
• Delete statement
• Update statement
• Objects Combine statement
• Objects Disaggregate statement
• Objects Erase statement
• Objects Intersect statement
• Objects Split statement
The following statements include a new BlockSize clause to specify the block size of a MapInfo
Native or NativeX (MapInfo Extended) files. Generally, the larger the block size, the faster the data
transfer rate.
• Commit Table statement
• Create Map statement
To support working with large values, MapBasic now uses the LargeInt variable for some functions
and statements, see Large Integer Variables. Also, the following functions have attributes that now
return a IntPtr value.
• SystemInfo() function return values SYS_INFO_APPLICATIONWND, SYS_INFO_MAPINFOWND,
SYS_INFO_MDICLIENTWND, and SYS_INFO_APPIDISPATCH.
• WindowInfo() function return value WIN_INFO_WND.
Additions from MapInfo Pro 15.0
The following additions were made in MapInfo Pro 15.0 (32-bit) and are included in this 64-bit release:
Alter Designer Frame statement - Lets you set the width and height of layout frames using the
new Height and Width clauses. Lets you set the name of an existing layout frame using the new
Name clause.
Create Frame statement - Create empty frames for the Layout window to add template functionality
for layouts and to create place-holders at any position of any valid frame size. For details, see Create
Empty Frames.
LayerInfo() function - Has a new attribute:
Map statement and Browse statement - Use the ID clause to insert open tables into the empty
layout frame. The frame properties already set for the empty frame are retained (pen, brush, position,
size, name, and z-order).
Set Designer Frame statement - A new funtion that converts a normal layout frame into an empty
frame, or converts an empty frame into a map frame or browser frame, by cloning an existing Map
or Browser window. Use the Clear attribute to turn a layout frame into an empty frame.
Set Layout statement - The new Selection clause changes the selection of frames in a Layout
window.
Set Map statement - A new FriendlyName clause sets a pretty (friendly) name for a layer, which
persists in the workspace. For details, see Managing Individual Layer Properties and Appearance.
Set Table statement - Use the Description clause to write a default pretty (friendly) name for a
layer to the TAB file’s Description field.
In this section
Function and Statement Conventions 44
Function and Statement Descriptions 44
A to Z MapBasic Language Reference
The following topics describe functions, statements, and clauses. Some topics provide more details
on how to apply a function or statement.
Abs() function
Purpose
Returns the absolute value of a number. You can call this function from the MapBasic window in
MapInfo Pro.
Syntax
Abs ( num_expr )
Return Value
Float
Description
The Abs() function returns the absolute value of the expression specified by num_expr.
If num_expr has a value greater than or equal to zero, Abs() returns a value equal to num_expr. If
num_expr has a negative value, Abs() returns a value equal to the value of num_expr multiplied by
negative one (-1).
Example
See Also:
Sgn() function
Acos() function
Purpose
Returns the arc-cosine value of a number. You can call this function from the MapBasic window in
MapInfo Pro.
Syntax
Acos ( num_expr )
Return Value
Float
Description
The Acos() function returns the arc-cosine of the numeric num_expr value. In other words, Acos()
returns the angle whose cosine is equal to num_expr.
The result returned from Acos() represents an angle, expressed in radians. This angle will be
somewhere between zero and Pi radians (given that Pi is equal to approximately 3.141593, and
given that Pi/2 radians represents 90 degrees).
To convert a degree value to radians, multiply that value by DEG_2_RAD. To convert a radian value
into degrees, multiply that value by RAD_2_DEG. Your program must Include MAPBASIC.DEF in
order to reference DEG_2_RAD or RAD_2_DEG.
Since cosine values range between one and negative one, the expression num_expr should represent
a value no larger than one and no smaller than negative one.
Example
Include "MAPBASIC.DEF"
Dim x, y As Float
x = 0.5
y = Acos(x) * RAD_2_DEG
' y will now be equal to 60,
' since the cosine of 60 degrees is 0.5
See Also:
Asin() function, Atn() function, Cos() function, Sin() function, Tan() function
ActiveWindow() function
Purpose
Returns current active window. You can call this function from the MapBasic window in MapInfo
Pro.
returns current docking manager active window in MapInfo Pro 64-bit.
Syntax
ActiveWindow ( )
Return Value
Integer
Syntax
legend_window_id is an integer window identifier that you can obtain by calling the FrontWindow()
function and WindowID() function.
def_frame_title is a string which defines a default frame title. It can include the special character "#"
which will be replaced by the current layer name.
def_frame_subtitle is a string which defines a default frame subtitle. It can include the special
character "#" which will be replaced by the current layer name.
def_frame_style is a string that displays next to each symbol in each frame. The "#" character will
be replaced with the layer name. The "%" character will be replaced by the text "Line", "Point,
"Region", as appropriate for the symbol. For example, "% of #" will expand to "Region of States" for
the STATES.TAB layer.
pen_expr is a Pen expression, for example, MakePen( width, pattern, color ). If a default border pen
is defined, then it will be become the default for the frame. If a border pen clause exists at the frame
level, then it is used instead of the default.
map_layer_id or map_layer_name identifies a map layer; can be a SmallInt (e.g., use 1 to specify
the top map layer other than Cosmetic) or a string representing the name of a table displayed in the
map. For a theme layer you must specify the map_layer_id.
paper_units is a string representing a paper unit name: cm (centimeters), mm (millimeters), in
(inches), pt (points), and pica.
• 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
• 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
• 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
• 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
• 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points
frame_title is a string which defines a frame title. If a Title clause is defined here for a frame, then
it will be used instead of the def_frame_title.
frame_subtitle is a string which defines a frame subtitle. If a SubTitle clause is defined here for a
frame, then it will be used instead of the def_frame_subtitle.
column is an attribute column name from the frame layer's table, or the object column (meaning
that legend styles are based on the unique styles in the mapfile). The default is 'object'.
style_name is a string which displays next to a symbol, line, or region in a custom frame.
Description
If the Custom keyword is included, then each frame section must include a Position clause. If
Custom is omitted and the legend is laid out in portrait or landscape, then the frames will be added
to the end.
The Position clause controls the frame's position on the legend window. The upper left corner of
the legend window has the position 0, 0. Position values use paper unit settings, such as "in"
(inches) or "cm" (centimeters) (see Set Paper Units statement). MapBasic has a current paper
units setting, which defaults to inches; a MapBasic program can change this setting through the Set
Paper Units statement.You can override the current paper units by including the optional Units
subclause within the Position clause.
The defaults in this statement apply only to the frames being created in this statement. They have
no affect on existing frames. Frame defaults used in the Create Cartographic Legend statement
have no affect on frames created in this statement.
When you save to a workspace, the FromMapCatalog OFF clause is written to the workspace
when specified. This requires the workspace version increasing to 800. If the FromMapCatalog
ON clause is specified, we do not write it to the workspace since it is default behavior. This lets us
avoid increasing the workspace version.
FromMapCatalog ON retrieves styles from the MapCatalog for a live access table. If the table is
not a live access table, MapBasic reverts to the default behavior for a non-live access table instead
of throwing an error. The default behavior for a non-access table is FromMapCatalog Off (for
example, map styles).
FromMapCatalog OFF retrieves the unique map styles for the live table from the server. This table
must be a live access table that supports per record styles for this to occur. If the live table does
not support per record styles than the behavior is to revert to the default behavior for live tables,
which is to get the default styles from the MapCatalog (FromMapCatalog ON).
Label is a valid expression or default (meaning that the default frame style pattern is used when
creating each style's text, unless the style clause contains text). The default is default.
The Style clause and the NoRefresh keyword allow you to create a custom frame that will not be
overwritten when the legend is refreshed. If the NoRefresh keyword is used in the Style clause,
then the table is not scanned for styles. Instead, the Style clause must contain your custom list of
definitions for the styles displayed in the frame. This is done with the Text and appropriate Line,
Region, or Symbol clause.
See Also:
Create Cartographic Legend statement, Set Cartographic Legend statement, Alter Cartographic
Frame statement, Remove Cartographic Frame statement
Syntax
Description
The Add Column statement creates a temporary new column for an existing MapInfo Pro table.
The new column will not be permanently saved to disk. However, if the temporary column is based
on base tables, and if you save a workspace while the temporary column is in use, the workspace
will include information about the temporary column, so that the temporary column will be rebuilt if
the workspace is reloaded. To add a permanent column to a table, use the Alter Table statement
and Update statement.
See Also:
Alter Table statement, Update statement
If both tables contain map objects, the Where clause can specify a geographic join. For example,
if you specify the clause Where Contains, MapInfo Pro constructs a join by testing whether objects
from the source_table contain objects from the table that is being modified.
The following example adds a "County" column to a "Stores" table. The new column will contain
county names, which are extracted from a separate table of county regions:
Add Column
stores(county char(20) 'add "county" column
From counties 'derive data from counties table...
Set to cname 'using the counties table's "cname" column
Where Contains 'join: where a county contains a store site
The Where Contains method is appropriate when you add a column to a table of point objects, and
the secondary table represents objects that contain the points.
The following example adds a temporary column to the States table. The new column values are
derived from a second table (City_1K, a table of major U.S. cities). After the completion of the Add
Column statement, each row in the States table will contain a count of how many major cities are
in that state.
The Set To clause in this example specifies an aggregate function, Count(*). Aggregate functions
are described below.
Max( col ) Largest of the values from rows in the source table.
Min( col ) Smallest of the values from rows in the source table.
Sum( col ) Sum of the values from rows in the source table.
WtAvg( col, weight_col ) Weighted average of the values from the source table; the
averaging is weighted so that rows having a large weight_col
value have more of an impact than rows having a small
weight_col value.
Proportion Avg( col ) Average calculation that makes adjustments based on how
much of an object is within another object.
Proportion Sum( col ) Sum calculation that makes adjustments based on how
much of an object is within another object.
Proportion WtAvg( col , weight_col ) Weighted average calculation that makes adjustments based
on how much of an object is within another object.
Note: Count returns an integer value. All other functions return a float value. (No MapBasic function,
aggregate or otherwise, returns a decimal value. A decimal field is only a way of storing the
data. The arithmetic is done with floating point numbers.)
Most of the aggregate functions operate on data values only. The last three functions (Proportion
Sum, Proportion Avg, Proportion WtAvg) perform calculations that take geographic relationships
into account. This is best illustrated by example.
Suppose you have a Counties table, containing county boundary regions and demographic information
(such as population) about each county. You also have a Risk table, which contains a region object.
The object in the Risk table represents some sort of area that is at risk; perhaps the region object
represents an area in danger of flooding due to proximity to a river.
For each county that is at least partly within the risk region, MapInfo Pro adds some or all of the
counties county_pop value to a running total.
The Proportion Sum function produces results based on an assumption―the assumption that the
number being totalled is distributed evenly throughout the region. If you use Proportion Sum to
process population statistics, and half of a region falls within another region, MapInfo Pro adds half
of the region's population to the total. In reality, however, an area representing half of a region does
not necessarily contain half of the region's population. For example, the population of New York
State is not evenly distributed, because a large percentage of the population lives in New York City.
If you use Proportion Sum in cases where the data values are not evenly distributed, the results
may not be realistic. To ensure accurate results, work with smaller region objects (for example,
operate on county regions instead of state regions).
The Proportion Avg aggregate function performs an average calculation which takes into account
the percentage of an object that is covered by another object. Continuing the previous example,
suppose the County table contains a column, median_age, that indicates the median age in each
county.
The following statement calculates the median age within the risk zone:
For each row in the County table, MapInfo Pro calculates the percentage of the risk region that is
covered by the county; that calculation produces a number between zero and one, inclusive. MapInfo
Pro multiplies that number by the county's median_age value, and adds the result to a running total.
Thus, if a county has a median_age value of 50, and if the county region covers 10% of the risk
region, MapInfo Pro adds 5 (five) to the running total, because 10% of 50 is 5.
Both Proportion Sum and Proportion Avg keep running totals. For example:
If half the county falls in the risk area, then you take half the value and add it to the running total. If
it is 10%, then you add 10% of the value to the running total. However, Proportion Avg should be
an average, so if 4 counties intersect the risk area, then you take the running total and divide by 4.
If county1 intersects the risk region, and 50% of county1 intersects the risk region, and the population
of county1 is 66, then you add 33 to the running total.
If 30% of county2's area intersects the risk area and the population is 100, then add 30 to the running
total.
If county3 has 20% overlap with the risk area and has a population of 50, then add 10 to the running
total.
If county4 has 10% overlap with the risk area and has a population of 60, then add 6 to the running
total.
Then the Proportion Sum is 33+30+10+6 = 82
Then the Proportion Avg is (33+30+10+6)/4 = 20 (or 21 depending on round off, but I think 20).
Proportion WtAvg is similar to Proportion Avg, but it also lets you specify a data column for
weighting the average calculation; the weighting is also proportionate. For example:
Weighted Average should take a weighted value from another column; for the previous example
there is another column called RuralPercent in the County table. If the risk is for flood and the rural
areas are where it floods, then for risk you only want the population from the rural area.
If county1 has 50% overlap with the risk region, a population of 66, and a RuralPercent of 0.8, then
add (0.5 * 66 * 0.8) = 26.
If county3, 4, and 5 are all 50% rural, then:
county3 0.3 * 100 * 0.5 = 15
Dynamic Columns
If you include the optional Dynamic keyword, the new column becomes a dynamic computed column,
meaning that subsequent changes made to the source table are automatically applied to the
destination table.
If you create a dynamic column, and then close the source table used to calculate the dynamic
column, the column values are frozen (the column is no longer updated dynamically).
Similarly, if a geographic join is used in the creation of a dynamic column, and you close either of
the maps used for the geographic join, the column values are frozen.
Syntax
Description
The Add Custom Frame statement is only for .wor persistence and .wor loading. Executing this
statement outside of loading a workspace (.wor), such as from a MapBasic window or MapBasic
tool, displays an error stating that the executed command is not supported from within the MapBasic
window or tool.
Custom frames cannot be cloned. Cloning a Layout window that has a custom frame in it causes
MapInfo Pro to clone all of the frames in the Layout window except for the custom frame.
Note: The Layout window scale bar is an example of a custom frame.
Syntax
legend_window_id is an integer window identifier that you can obtain by calling the FrontWindow(
) function and WindowID( ) function.
map_layer_id or map_layer_name identifies a map layer; can be a SmallInt (e.g., use 1 to specify
the top map layer other than Cosmetic) or a string representing the name of a table displayed in the
map. For a theme layer you must specify the map_layer_id.
paper_units is a string representing a paper unit name: cm (centimeters), mm (millimeters), in
(inches), pt (points), and pica.
• 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
• 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
• 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
• 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
• 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points
win_height is a string specifying the legned frame height in paper units. For details about paper
units, see Set Paper Units statement.
frame_title is a string which defines a frame title. If a Title clause is defined here for a frame, then
it will be used instead of the def_frame_title.
frame_subtitle is a string which defines a frame subtitle. If a SubTitle clause is defined here for a
frame, then it will be used instead of the def_frame_subtitle.
column is an attribute column name from the frame layer's table, or the object column (meaning
that legend styles are based on the unique styles in the mapfile). The default is 'object'.
number_of_columns is the number of columns to show in a frame.
frame_height this is used in place of the column clause when the user resizes a legend frame. The
height of the frame in paper units. Written to the WOR when the frame has been manually resized.
style_name is a string which displays next to a symbol, line, or region in a custom frame.
Description
The default properties set in the Create Designer Legend statement are used when adding new
frames. You override these default properties when you explicitly set properties for the frames that
you are adding. Unlike the Add Cartographic Frame statement, the Add Designer Frame statement
supports a Columns clause that lets you specify how many columns to use in a legend frame.
If the Custom keyword is included, then each frame section must include a Position clause. If
Custom is omitted and the legend is laid out in portrait or landscape, then the frames will be added
to the end.
The Frame From Layer may be a (SmallInt) value, such as 1 to specify the top map layer other
than the Cosmetic layer, or a string representing the layer name in an existing map. For a theme
layer you must specify the map_layer_id.
The Position clause controls the frame's position on the Legend window. The upper left corner of
the Legend window has the position 0, 0. Position values use paper units settings, such as "in"
(inches) or "cm" (centimeters). MapBasic has a current paper units setting, which defaults to inches;
a MapBasic program can change this setting through the Set Paper Units statement.You can
override the current paper units by including the optional Units subclause within the Position clause.
The defaults in this statement apply only to the frames being created in this statement. They have
no affect on existing frames. Frame defaults used in the Create Cartographic Legend statement
have no affect on frames created in this statement.
The Column clause is an attribute column name from the frame layer's table, or the object column
(legend styles are based on the unique styles in the .map file). The default is object.
When you save to a workspace, the FromMapCatalog OFF clause is written to the workspace
when specified. This requires the workspace to bumped up to 800. If the FromMapCatalog ON
clause is specified, we do not write it to the workspace since it is default behavior. This lets us avoid
bumping up the workspace version in this case.
FromMapCatalog ON retrieves styles from the MapCatalog for a live access table. If the table is
not a live access table, MapBasic reverts to the default behavior for a non-live access table instead
of throwing an error. The default behavior for a non-access table is FromMapCatalog Off (for
example, map styles).
FromMapCatalog OFF retrieves the unique map styles for the live table from the server. This table
must be a live access table that supports per record styles for this to occur. If the live table does
not support per record styles than the behavior is to revert to the default behavior for live tables,
which is to get the default styles from the MapCatalog (FromMapCatalog ON).
Label is a valid expression or default (the default frame style pattern is used when creating each
style's text, unless the style clause contains text). The default is default.
The Title clause is a string that defines a frame title. If a Title clause is defined for a frame, then it
will be used instead of def_frame_title.
The SubTitle clause is a string that defines a frame subtitle. If a SubTitle clause is defined for a
frame, then it will be used instead of def_frame_subtitle.
The Columns clause is the number of columns to show within a frame.
paper_units is a string representing a paper unit name. For details about paper units, see Set Paper
Units statement.
The Style clause and the NoRefresh keyword allow you to create a custom frame that will not be
overwritten when the legend is refreshed. If the NoRefresh keyword is used in the Style clause,
then the table is not scanned for styles. Instead, the Style clause must contain your custom list of
definitions for the styles displayed in the frame. This is done with the Text and appropriate Line,
Region, or Symbol clause.
Take note of the following:
• When adding legend frames from MapInfo Pro, new frames are selected.
• when adding legend frames from MapBasic, new frames are not selected and the previous selection
remains unchanged.
• The LayoutInfo( ) function includes theme legends in its frame count.
Examples
You can get an count of open document windows using NumAllWindows( ) function, then loop
through them using WindowID( ) function or WindowInfo( ) function to find the legend window
by type and its window ID to use with the Add Legend Designer statement.
To get the window identifier use the following where window_id is an integer window identifier for
a Layout window and frame_id is a number that specifies which frame within the Layout window
you want to query.
For example, if a layout has one map frame and one or more legends, then the map frame is
frame_id 1 and the first legend is 2. The following will return window identifier for the Legend
window where 2 is a legend frame:
You can use the results of the above in a statement to add legends:
See Also:
Create Designer Legend statement, Set Designer Legend statement, Add Designer Frame
statement, Add Designer Text statement, Add Image Frame statement, Add Image Page
statement, Alter Designer Frame statement, Remove Designer Frame statement
Syntax
Description
The Add Designer Page statement adds one page to the Layout window. The page is added at
the end of the collection of pages (at the end of the thumbnails). There is no limit to the number of
pages you can add, it only depends on available memory.
See Also:
Create Designer Legend statement, Add Designer Frame statement, Add Designer Text
statement, Add Image Frame statement, Remove Designer Page statement
Syntax
legend_window_id is an integer window identifier that you can obtain by calling the FrontWindow()
function and WindowID() function.
frame_text is text for a legend title, subtitle, or descriptive text (such as copyright information for
example).
x states the desired distance from the top of the workspace to the top edge of the window.
y states the desired distance from the left of the workspace to the left edge of the window.
Note: Here workspace means the client area (which excludes the title bar, tool bar, and the status
bar).
Description
Legend Text Frame creates a text frame in the Legend window.
If Text does not specify the Font clause, then the default font is used.
The Position clause controls the frame's position on the Legend window. The upper left corner of
the Legend window has the position 0, 0. Position values use paper units settings, such as "in"
(inches) or "cm" (centimeters) (see Set Paper Units statement). MapBasic has a current paper
units setting, which defaults to inches; a MapBasic program can change this setting through the Set
Paper Units statement. You can override the current paper units by including the optional Units
subclause within the Position clause.
Example
See Also:
Create Designer Legend statement, Add Designer Frame statement, Add Designer Text
statement, Add Image Frame statement, Add Image Page statement, Alter Designer Text
statement, Remove Designer Text statement
Syntax
Description
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.
An optional Position clause lets you place the image frame within the Layout window. If it is omitted,
then the image is centered in the visible area of the layout.
The optional Width and Height clauses specify the size of the image frame, in paper units. If no
Width and Height clauses are provided, then the image dimensions are used. If only one value is
specified, then it is used to calculate the missing value and still maintain the aspect ration of the
image.
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.
See Also:
Add Designer Frame statement, Add Designer Text statement, Add Image Frame statement,
Add Image Page statement, FrontWindow() function, Set Paper Units statement, WindowID()
function
Syntax 1
Add Map
[ Window window_id ] [ Auto ]
Layer table [ , table [ Animate ] ... ]
[ [ DestGroupLayer group_id ] Position position ]
Syntax 2
Add Map
[ Window window_id ] [ Auto ]
GroupLayer ( "friendly_name" [ , item ... ] )
[ [ DestGroupLayer group_id ] Position position ]
where:
Description
The Add Map statement adds one or more open tables, or a group layer, to a Map window, but not
both within the same statement. The group layer may contain any number of nested group layers.
MapInfo Pro then automatically redraws the Map window, unless you have suppressed redraws
through a Set Event Processing statement Off statement or Set Map statement Redraw Off
statement.
The window_id parameter is an integer window identifier representing an open Map window; you
can obtain a window identifier by calling the FrontWindow() function and WindowID() function.
If the Add Map statement does not specify a window_id value, the statement affects the topmost
Map window.
If you include the optional Auto keyword, MapInfo Pro tries to automatically position the map layer,
or group layers at an appropriate place in the set of layers. A raster table or a map of region objects
would be placed closer to the bottom of the map, while a map of point objects would be placed on
top.
If you omit the Auto keyword, the specified table becomes the topmost layer in the window; in other
words, when the map is redrawn, the new layer, or group layers will be drawn last. You can then
use the Set Map statement to alter the order of layers in the Map window.
If a DestGroupLayer is specified the Auto keyword will be ignored and the list of layers, or the group
layer will be inserted into the layer list, in the group specified, at the position specified. A group id
of 0 is the top level list. If the DestGroupLayer is omitted the group ID defaults to 0.
The position is the 1-based index within the destination group of where to insert the new list of layers.
If the position is omitted it is assumed to be the first position in the group (position = 1). If the position
given exceeds the number of items in the destination group, the new layers and/or groups will be
inserted at the end of the destination group.
Layer and group IDs may be the numeric ID or name. Group IDs range from 0 to the total number
of groups in the list.
Note: You cannot insert into the middle of a set of thematic layers. Thematic layers are inserted
in a certain order as they are created and this order is maintained. If the destination position
would cause the new layers to be inserted within a set of thematic layers, the final position
will be adjusted to avoid that.
In general, the last table to be followed by the Animate keyword will be the animation layer. Only
one layer at a time can be the Animation layer.
To terminate the animation layer processing, issue a Remove Map statement Layer Animate
statement.
Animation layers have special restrictions. For example, users cannot use the Info tool to click on
objects in an animation layer. Also, each Map window can have only one animation layer. For more
information about animation layers, see the MapBasic User's Guide.
Example
See Also:
Map statement, Remove Map statement, Set Map statement
AdornmentInfo() function
Purpose
Returns information about adornments like scale bars. You can call this function from the MapBasic
window in MapInfo Pro.
Syntax
Return Value
Float, smallint, integer, logical, pen, brush, font, or string, depending on the attribute parameter.
Description
There are several attributes that AdornmentInfo() can return. Codes are defined in MAPBASIC.DEF.
ADORNMENT_INFO_IS_FIXED_POS 3 Logical. True for fixed position, false for docked position.
ADORNMENT_INFO_FIXED_POS_UNITS 6 Char. Units of the X and Y offsets for the docked position.
ADORNMENT_INFO_DOCKED_UNITS 10 Char. Units of the X and Y offsets for the docked position.
ADORNMENT_INFO_SB_PAPER_UNITS 22 Char. Paper units in the scale bar. For details about paper units,
see Set Paper Units statement.
ADORNMENT_INFO_SB_BAR_PEN 28 Pen. The pen style used to draw the scale bar.
ADORNMENT_INFO_SB_BAR_BRUSH 29 Brush. The brush, fill style used to draw the scale bar.
ADORNMENT_INFO_SB_BAR_FONT 30 Font. The font used to render text in the scale bar.
ADORNMENT_INFO_SB_DISPLAY_SCALE 31 Float. The numeric value of the scale that will be shown in the scale
bar.
ADORNMENT_INFO_SB_AUTOOFF_SCALE 32 Float. The unrounded scale value that is used if auto scaling is off.
ADORNMENT_INFO_SB_AUTOON_SCALE 33 Float. The rounded scale value that is used if auto scaling is on.
ADORNMENT_INFO_SB_SCALE_STRING 34 Char. The scale value that is being displayed but as a formatted
string (such as decimal points, thousands separators).
Example
Syntax
handler is the handler that is already assigned to an existing button. The handler can be the name
of a MapBasic procedure, or a standard command code (e.g., M_TOOLS_RULER or
M_WINDOW_LEGEND) from MENU.DEF.
Description
If the Alter Button statement specifies a handler (e.g., a procedure name), MapInfo Pro modifies
all buttons that call that handler. If the statement specifies a button_id number, MapInfo Pro modifies
only the button that has that ID.
The Disable keyword changes the button to a grayed-out state, so that the user cannot select the
button.
The Enable keyword enables a button that was previously disabled.
The Check and Uncheck keywords select and deselect ToggleButton type buttons, such as the
Show Statistics Window button. The Check keyword has the effect of "pushing in" a ToggleButton
control, and the Uncheck keyword has the effect of releasing the button. For example, the following
statement selects the Show Statistics Window button:
Note: Checking or unchecking a standard MapInfo Pro button does not automatically invoke that
button's action; thus, checking the Show/Hide Statistics button does not actually show the
Statistics window-it only affects the appearance of the button. To invoke an action as if the
user had checked or unchecked the button, issue the appropriate statement; in this example,
the appropriate statement is the Open Window statement Statistics.
Similarly, you can use the Check keyword to change the appearance of a ToolButton. However,
checking a ToolButton does not actually select that tool, it only changes the appearance of the
button. To make a standard tool the active tool, issue a Run Menu Command statement, such as
the following:
To make a custom tool the active tool, use the syntax Run Menu Command ID IDnum.
Things to remember when using this command with the MapInfo Pro 64-bit:
1. This command allows you to enable\disable or select\unselect a control added to ButtonPad
group.
2. If you check/uncheck using a mapinfo run menu command then controls which have an ischecked
property bind are affected.
See Also:
Alter ButtonPad statement, Create ButtonPad statement, Run Menu Command statement
Syntax
row, column specify the toolbar's position when docked (e.g., 0, 0 places the pad at the left edge of
the top row of toolbars, and 0, 1 represents the second toolbar on the top row). Not suppported in
the 64-bit version of MapInfo Pro.
• row position starts at the top and increases in value going to the bottom. It is a relative value to
the rows existing in the same position (top or bottom). When there is a menu bar in the same
position, then the numbers become relative to the menu bar. When a toolbar is just below the
menu bar, its row value is 0. If it is directly above the menu bar, then its row value is -1.
• column position starts at the left and increases in value going to the right. It is a relative value to
the columns existing in the same position (left or right). For example, if a toolbar is docked to the
left and the menu bar is docked to the left position, then the column number for the column left of
the menu bar is -1. The column number for the column to the right of the menu bar is 0.
Each button_definition clause can consist of the keyword Separator, or it can have the following
syntax:
Cursor cursor_code specifies the shape the mouse cursor should adopt whenever the user chooses
a ToolButton tool; cursor_code is a code, such as MI_CURSOR_ARROW (0), from ICONS.DEF.
This clause applies only to ToolButtons. If the File sub-clause specifies the name of a file containing
icon resources, cursor_code is an integer resource ID identifying a resource in the file.
The 64-bit version of MapInfo Pro supports cursors in three ways:
1. As a string from Icons.def: SetRbnToolBtnCtrlCursor(MyToolButton, "138")
2. As a string with keyword FILE and name of DLL with custom cursors:
SetRbnToolBtnCtrlCursor(MyToolButton, "136 FILE gcsres32.dll")
3. As an integer id such as a MapInfo Cursor define from Icons.def:
SetRbnToolBtnCtrlCursorId(MyToolButton, MI_CURSOR_FINGER_LEFT)
dm_code specifies whether the user can click and drag, or only click with the tool; dm_code is a
code, such as DM_CUSTOM_LINE (33), from ICONS.DEF. Applies only to ToolButtons.
msg is a string that specifies the button's status bar help and, optionally, ToolTip help. The first part
of msg is the status bar help message. If the msg string includes the letters \n then the text following
the \n is used as the button's ToolTip help.
The ModifierKeys clause applies only to ToolButtons; it controls whether the Shift and control
(Ctrl) keys affect "rubber-band" drawing if the user drags the mouse while using a ToolButton.
Default is Off (modifier keys have no effect).
Description
Use the Alter ButtonPad statement to show, hide, modify, or destroy an existing ButtonPad. For
an introduction to ButtonPads, see the MapBasic User Guide.
To show or hide a ButtonPad, include the Show or Hide keyword; see example below.
To set whether the pad is fixed to the top of the screen ("docked") or floating like a window, include
the Fixed or the Float keyword. The user can also control whether the pad is docked or not by
dragging the pad to or from the top of the screen. For more control over the location on the screen
that the pad is docked to, use the Top (which is the same as using Fixed), Left, Right, or Bottom
keywords.
When a pad is floating, its position is controlled by the Position clause; when a pad is docked, its
position is controlled by the ToolbarPosition clause.
To destroy a ButtonPad, include the Destroy keyword. Once a ButtonPad is destroyed, it no longer
appears in the Toolbars dialog box.
The Alter ButtonPad statement can add buttons to existing ButtonPads, such as Main and Drawing.
There are three types of button controls you can add: PushButton controls (which the user can click
and release-for example, to display a dialog box); ToggleButton controls (which the user can select
by clicking, then deselect by clicking again); and ToolButton controls (which the user can select,
and then use for clicking on a Map window or layout).
If you include the optional Disable keyword when adding a button, the button is disabled (grayed
out) when it appears. Subsequent Alter Button statements can enable the button. However, if the
button's handler is a standard MapInfo Pro command, MapInfo Pro automatically enables or disables
the button depending on whether the command is currently enabled.
If you include the optional Check keyword when adding a ToggleButton or a ToolButton, the button
is automatically selected ("checked") when it first appears.
If the user clicks while using a custom ToolButton tool, MapInfo Pro automatically calls the tool's
handler, unless the user cancels (e.g., by pressing the Esc key while dragging the mouse). A handler
procedure can call CommandInfo() to determine where the user clicked. If two or more tools call
the same handler procedure, the procedure can call CommandInfo() to determine the ID of the
button currently in use.
The File file_spec sub-clause refers to a DLL file that contains bitmap resources; the n parameter
refers to the ID of a bitmap resource. For more information on creating Windows icons, see the
MapBasic User Guide.
A ToolButton definition also can include a Cursor clause, which controls the appearance of the
mouse cursor while the user is using the custom tool. Available cursor codes are listed in ICONS.DEF,
such as MI_CURSOR_CROSSHAIR (138) or MI_CURSOR_ARROW (0). The procedure for specifying
a custom cursor is similar to the procedure for specifying a custom icon.
For custom icon size requirements for different MapInfo Pro versions, see Create ButtonPad
statement About Icon Size.
DM_CUSTOM_POINT 34 The user cannot drag while using the custom tool.
DM_CUSTOM_LINE 33 As the user drags, a line connects the cursor with the location where
the user clicked.
DM_CUSTOM_ELLIPSE 31 As the user drags, an elliptical marquee appears; if you include the
ModifierKeys clause, the user can force the marquee to a circular
shape by holding down the Shift key.
DM_CUSTOM_POLYGON 35 The user may draw a polygon. To retrieve the object drawn by the
user, use the function call: CommandInfo() function
(CMD_INFO_CUSTOM_OBJ).
DM_CUSTOM_POLYLINE 36 The user may draw a polyline. To retrieve the object drawn by the
user, use the function call: CommandInfo() function
(CMD_INFO_CUSTOM_OBJ).
All of the draw modes except for DM_CUSTOM_POINT (34) support the Autoscroll feature, which
allows the user to scroll a Map or layout by clicking and dragging to the edge of the window. To
disable autoscroll, see Set Window statement.
Note: MapBasic supports an additional draw mode that is not available to MapInfo Pro users. If a
custom ToolButton has the following Calling clause Calling M_TOOLS_SEARCH_POLYGON
(1733) then the tool allows the user to draw a polygon. When the user double-clicks to close
the polygon, MapInfo Pro selects all objects (from selectable map layers) within the polygon.
The polygon is not saved.
Examples
The following example shows the Main ButtonPad and hides the Drawing ButtonPad:
The next example docks the Main ButtonPad and sets its docked position to 0,0 (upper left):
The next example moves the Main ButtonPad so that it is floating instead of docked, and sets its
floating position to half an inch inside the upper-left corner of the screen.
The sample program, ScaleBar, contains the following Alter ButtonPad statement, which adds a
custom ToolButton to the Tools ButtonPad. (Note that "ID 3" identifies the Tools ButtonPad.)
Alter ButtonPad ID 3
Add
Separator
ToolButton
Icon MI_ICON_CROSSHAIR
HelpMsg "Draw a distance scale on a map\nScale Bar"
Cursor MI_CURSOR_CROSSHAIR
DrawMode DM_CUSTOM_POINT
Calling custom_tool_routine
Show
Note: The Separator keyword inserts space between the last button on the Tools ButtonPad and
the new MI_CURSOR_CROSSHAIR (138) button.
See Also:
Alter Button statement, ButtonPadInfo() function, Create ButtonPad statement, Set Window
statement
Syntax
legend_window_id is an integer window identifier that you can obtain by calling the FrontWindow()
function and WindowID() function.
frame_id is the ID of the frame on the legend. You cannot use a layer name. For example, three
frames on a legend would have the successive ID's 1, 2, and 3.
x, y specifies the position of the upper left corner of the legend frame, in paper_units, in the Layout
window.
paper_units is a string representing a paper unit name: cm (centimeters), mm (millimeters), in
(inches), pt (points), and pica.
• 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
• 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
• 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
• 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
• 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points
frame_title is a string which defines a frame title.
frame_subtitle is a string which defines a frame subtitle.
id is the position within the style list for that frame. To get information about the number of styles in
a frame, use the LegendFrameInfo() function with attribute FRAME_NUM_STYLES (13).
style_name is a string that displays next to each symbol for the frame specified in ID. The "#"
character will be replaced with the layer name. The "%" character will be replaced by the text "Line",
"Point, "Region", as appropriate for the symbol. For example, "% of #" will expand to "Region of
States" for the frame corresponding to the STATES.TAB layer.
Description
If a Window clause is not specified MapInfo Pro will use the topmost legend window.
The Position clause controls the frame's position on the legend window. The upper left corner of
the legend window has the position 0, 0. Position values use paper units settings, such as "in"
(inches) or "cm" (centimeters) (see Set Paper Units statement). MapBasic has a current paper
units setting, which defaults to inches; a MapBasic program can change this setting through the Set
Paper Units statement. An Alter Cartographic Frame statement can override the current paper
units by including the optional Units subclause within the Position clause.
The Title and SubTitle clauses accept new text, new font or both.
The Style clause must contain a list of definitions for the styles displayed in frame. You can only
update the Style type for a custom style. You can update the Text of any style. There is no way to
add or remove styles from any type of frame.
See Also:
Create Cartographic Legend statement, Set Cartographic Legend statement, Add Cartographic
Frame statement, Remove Cartographic Frame statement
Syntax
id_num is an integer identifying one of the controls in the active dialog box.
title is a string representing the new title to assign to the control.
array_name is the name of an array variable; used to reset the contents of ListBox, MultiListBox,
and PopupMenu controls.
value is the new value to associate with the specified control.
Restrictions
You cannot issue this statement through the MapBasic window.
Description
The Alter Control statement modifies one or more attributes of a control in the active dialog box;
accordingly, the Alter Control statement should only be issued while a dialog box is active (for
example, from within a handler procedure that is called by one of the dialog box controls). If there
are two or more nested dialog boxes on the screen, the Alter Control statement only affects controls
within the topmost dialog box.
The id_num specifies which dialog box control should be modified; this corresponds to the id_num
parameter specified within the ID clause of the Dialog statement.
Each of the optional clauses (Title, Value, Enable/Disable, Hide/Show, Active) modifies a different
attribute of a dialog box control. Note that all of these clauses can be included in a single statement;
thus, a single Alter Control statement could change the name, the value, and the enabled/disabled
status of a dialog box control.
Some attributes do not apply to all types of controls. For example, a Button control may be enabled
or disabled, but has no value attribute.
The Title clause resets the text that appears on most controls (except for Picker controls and EditText
controls; to reset the contents of an EditText control, set its Value). If the control is a ListBox,
MultiListBox, or PopupMenu control, the Title clause can read the control's new contents from an
array of string variables, by specifying a From Variable clause.
The Active keyword applies only to EditText controls. An Alter Control...Active statement puts the
keyboard focus on the specified EditText control.
Use the Hide and Show keywords to make controls disappear or reappear.
To de-select all items in a MultiListBox control, use a value setting of zero. To add a list item to the
set of selected MultiListBox items, issue an Alter Control statement with a positive integer value
corresponding to the number of the list item.
Note: In this case, do not issue the Alter Control statement from within the MultiListBox control's
handler.
You can use an Alter Control statement to modify the text that appears in a StaticText control.
However, MapInfo Pro cannot increase the size of the StaticText control after it is created. Therefore,
if you plan to alter the length of a StaticText control, you may want to pad it with spaces when you
first define it. For example, your Dialog statement could include the following clause:
Example
The following example creates a dialog box containing two check boxes, an OK button, and a Cancel
button. Initially, the OK button is disabled (grayed out). The OK button is only enabled if the user
selects one or both of the check boxes.
Include "mapbasic.def"
Declare Sub Main
Declare Sub checker
Sub Main
Dim browse_it, map_it As Logical
Dialog
Title "Display a file"
Control CheckBox
Title "Display in a Browse window"
Value 0
Calling checker
ID 1
Into browse_it
Control CheckBox
Title "Display in a Map window"
Value 0
Calling checker
ID 2
Into map_it
Control CancelButton
Control OKButton
ID 3
Disable
If CommandInfo(CMD_INFO_DLG_OK) Then
' ... then the user clicked OK...
End If
End Sub
Sub checker
' If either check box is checked,
' enable the OK button; otherwise, Disable it.
If ReadControlValue(1) Or ReadControlValue(2) Then
Alter Control 3 Enable
Else
Alter Control 3 Disable
End If
End Sub
Syntax
[ , ... ]
[ Angle frame_angle ]
legend_or_layout_window_id is an integer window identifier for the Legend or Layout window that
you can obtain by calling the FrontWindow() function and WindowID() function.
frame_id is the ID of the frame. You cannot use a layer name. For example, three frames would
have the successive ID's 1, 2, and 3.
paper_units is a string representing a paper unit name: cm (centimeters), mm (millimeters), in
(inches), pt (points), and pica. For details about paper units, see Set Paper Units statement.
• 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
• 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
• 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
• 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
• 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points
frame_title is a string which defines a frame title.
frame_subtitle is a string which defines a frame subtitle.
number_of_columns is the number of columns to show in a frame.
frame_height this is used in place of the column clause when the user resizes a legend or layout
frame. The height of the frame in paper units. Written to the WOR when the frame has been manually
resized.
frame_width is width of the frame in paper units. Written to the WOR when the frame has been
manually resized. The width cannot be specified for a Legend frame.
frame_name is a string representing the name for a frame in a Layout window. The frame_name
cannot be specified for a Legend frame. If a name is assigned to a frame in the Layout window, it
is written to the workspace (WOR file) and the workspace version is updated to 1500.
region_height is a value representing the new height of a swatch in the map frame of the Lengend
or Layout window. You can specify 8 to 144 points, 0.666667 to 12 picas, 0.111111 to 2 inches,
0.282222 to 5.08 millimeters, or 0.282222 to 5.08 centimeters. If not specified, then the default value
of 32 points is used (which can be set as a preference).
region_width is a value representing the new width of a swatch in the map frame of the Legend or
Layout window window. You can specify 8 to 144 points, 0.666667 to 12 picas, 0.111111 to 2
inches, 0.282222 to 5.08 millimeters, or 0.282222 to 5.08 centimeters. If not specified, then the
default value of 32 points is used (which can be set as a preference).
line_width is a value representing the new width of a line segment in the map frame of a Legend
or Layout window. You can specify 12 to 144 points, 1 to 12 picas, 0.666667 to 2 inches, 4.23333
to 50.8 millimeters, or 4.23333 to 50.8 centimeters. If not specified, then the default value of 36
points is used (which can be set as a preference).
id is the position within the style list for that frame. To get information about the number of styles in
a frame, use the LegendFrameInfo() function with attribute FRAME_NUM_STYLES (13).
style_name is a string that displays next to each symbol for the frame specified in ID. The "#"
character will be replaced with the layer name. The "%" character will be replaced by the text "Line",
"Point, "Region", as appropriate for the symbol. For example, "% of #" will expand to "Region of
States" for the frame corresponding to the STATES.TAB layer.
frame_angle is a float value indicating the angle of rotation for a text frame only (in degrees).
Description
If you omit the Window clause, the statement operates on the frontmost window, or the frontmost
Legend or Layout window as the case may be.
The Position clause controls the frame's position on the Legend or Layout window. The upper left
corner of the window has the position 0, 0. Position values use paper units settings, such as "in"
(inches) or "cm" (centimeters). MapBasic has a current paper units setting, which defaults to inches;
a MapBasic program can change this setting through the Set Paper Units statement. An Alter
Designer Frame statement can override the current paper units by including the optional Units
subclause within the Position clause.
The Title and SubTitle clauses accept new text, new font clause or both.
The Columns clause is the number of columns to show within a frame.
All frame types have a minimum and maximum Height and Width. If you set an out of range
frame_width or frame_height, an error message appears showing the allowed range.
• In case of an image frame, the aspect ratio is always maintained. For example, for an image having
aspect ratio 0.5
If both Width and Height are specified within the same statement, the last clause takes precedence.
In the following case, the height will be set to 100 and width to 200 to preserve the aspect ratio.
• In case of a frame containing a line shape, if Width is set to zero then the line will be vertical. Set
Height to zero for a horizontal line. If both the width and height are set to zero, an error message
appears.
The Region Height clause specifies a specific height for a swatch in the legend frame of the Legend
window.
The Region Width clause specifies a specific width for a swatch in the legend frame of the Legend
window.
The Line Width clause specifies a specific width for a line sample in the legend frame of the Legend
window.
Auto Font Size enables or disables resizing the legend swatch based on the font size setting.
The Order clause adds the ability to sort or customize the order of rows in map legends. You can
sort map legends by style label or by defining your own order. The sort order options are Default,
Ascending, Descending, or Custom. The Order clause is only written to a workspace if the map
legend is sorted ascending, descending, or custom.
A Default sort order is the order the Create Legend wizard creates the legend rows. If you create
a legend based on unique styles, this will be the order of those styles, which then display as rows
in the map legend.
If specifying Custom sort order, the id values are row ids starting with 1, moving from top to bottom.
When looking at the list of rows in the Legend Frame Properties dialog box, the first row in the list
has id equal to 1 and so on down the list. For more details, see Custom Order Options for more
details.
The Display clause controls the display of each row. Each row in MapBasic starts with the Style
clause. At the end of each Style clause is the optional Display clause. Display On makes the row
visible. Display Off makes the row invisible. If the Display clause is absent, then the row displays.
The Display clause is only written to a workspace file for styles that are not visible in a frame.
Note: The Columns or Height clauses apply to map and thematic legends. However, all other
thematic legend properties must be specified using the Set Legend statement.
The paper Units are cm (centimeters), mm (millimeters), in (inches), pt (points), and pica. Conversions
between these units are:
• 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
• 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
• 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
• 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
• 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points
The Style clause must contain a list of definitions for the styles displayed in frame. You can only
update the Style type for a legend frame created with the NoRefresh keyword. You can update the
Text of any style. There is no way to add or remove styles from any type of frame.
Only the following clauses will be applied to thematic legends. Those are:
[ Columns number_of_columns ] |
[ Height frame_height [ Units paper_units ] ]
Example
The following example alters Frame 1 style sample 1 from a Cities points layer. It updates the title,
subtitle, and text shown next to its symbols.
See Also:
Add Designer Frame statement, Create Designer Legend statement, Remove Designer Frame
statement, Set Designer Legend statement
Custom id | id : id [ , id | id : id ... ]
Where the following specifies a range of row ids in increasing order (Id2 > Id1):
Id1 : Id2
Reordering a List
The syntax for custom order of legend rows is similar to the Order clause (to reorder layers) in the
Set Map statement. It is fairly easy to use when you want to reorder near the beginning of a list,
but not so easy when you want to reorder near the end. For instance, if you want to reverse the
order of the first three rows you only have to use:
Order Custom 3, 2, 1
You can leave out the rest of the rows. If you have 10 rows and want to switch the last two, you
have to list all the ids like this:
Long form:
Order Custom 2, 5, 6, 7, 8, 9, 10, 1, 3, 4
Short form:
Order Custom 2, 5:10, 1, 3, 4
Order Custom 2, 5:10, 1, 3:4 (same as above but also valid)
Order Custom 2, 5:10, 1 (same as above but also valid)
Long form:
Order Custom 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18,
19, 20, 11
Short form:
Order Custom 1:10, 12:20, 11
The list of values cannot have duplicates that will cause an error. The following causes an error:
This is because row ids 4 and 5 are duplicates. To see this, expand the syntax as follows (which
causes an error):
Order Custom 1, 2, 3, 4, 5, 8, 4, 5, 6, 7
The alternate syntax can be used when creating or altering a legend in the Legend window. For
workspaces, the short syntax is used when legends in the Legend window have more than 50 rows
with a custom order.
Syntax
frame_text is text for a legend title, subtitle, or descriptive text (such as copyright information for
example).
x states the desired distance from the top of the workspace to the top edge of the window.
y states the desired distance from the left of the workspace to the left edge of the window.
Note: Here workspace means the client area (which excludes the title bar, tool bar, and the status
bar).
Description
If Text does not specify the Font clause, then the default font is used.
The Position clause controls the frame's position on the Legend window or the Layout window.
The upper left corner of the window has the position 0, 0. Position values use paper units settings,
such as "in" (inches) or "cm" (centimeters) (see Set Paper Units statement). MapBasic has a
current paper units setting, which defaults to inches; a MapBasic program can change this setting
through the Set Paper Units statement. You can override the current paper units by including the
optional Units subclause within the Position clause.
If you omit the Window clause, the statement operates on the frontmost open window, or the
frontmost Legend window, or the frontmost Layout window.
Example
See Also:
Create Designer Legend statement, Add Designer Text statement, Remove Designer Text
statement
Restrictions
Caution: The Alter MapInfoDialog statement may not be supported in future versions of MapInfo
Pro. As a result, MapBasic programs that use this statement may not work correctly when
run using future versions of MapInfo Pro. Use this statement with caution.
dialog_ID is an integer ID number, indicating which MapInfo Pro dialog box to alter.
control_ID is an integer ID number, 1 or larger, indicating which control to modify.
new_value is a new value assigned to the dialog box control.
Description
Use this statement if you need to disable, hide, or assign new values to controls―buttons, check
boxes, etc.―in MapInfo Pro's standard dialog boxes.
Note: Use this statement to modify only MapInfo Pro's standard dialog boxes. To modify custom
dialog boxes that you create using the Dialog statement, use the Alter Control statement.
Determining ID Numbers
To determine a dialog box's ID number, run MapInfo Pro with this command line:
mapinfopro.exe -helpdiag
After you run MapInfo Pro with the -helpdiag argument, display a MapInfo Pro dialog box and click
the Help button. Ordinarily, the Help button launches Help, but because you used the -helpdiag
argument, MapInfo Pro displays the ID number of the current dialog box.
Note: There are different "common dialog boxes" (such as the Open and Save dialog boxes) for
different versions of Windows. If you want to modify a common dialog box, and if your
application will be used under different versions of Windows, you may need to issue two
Alter MapInfoDialog statements, ne for each version of the common dialog box.
Each individual control has an ID number. For example, most OK buttons have an ID number of 1,
and most Cancel buttons have an ID number of 2. To determine the ID number for a specific control,
you must use a third-party developer's utility, such as the Spy++ utility that Microsoft provides with
its C compiler. The MapBasic software does not provide a Spy++ utility.
Although the Alter MapInfoDialog statement changes the initial appearance of a dialog box, the
changes do not have any effect unless the user clicks OK. For example, you can use Alter
MapInfoDialog to store an address in the Find dialog box; however, MapInfo Pro will not perform
the Find operation unless you display the dialog box and the user clicks OK.
Example
The following example alters MapInfo Pro's Find dialog box by storing a text string ("23 Main St.")
in the first edit box and hiding the Respecify button.
The ID number 2202 refers to the Find dialog box. Control 5 is the edit box where the user types
an address. Control 12 is the Respecify button, which this example hides. All ID numbers are subject
to change in future versions of MapInfo Pro; therefore, this example calls the SystemInfo() function
to determine the MapInfo Pro version number.
See Also:
Alter Control statement, SystemInfo() function
Syntax 1
newmenuitem
[ ID menu_item_id ]
[ HelpMsg help ]
[ { Calling handler | As menuname } ]
Syntax 2
Description
The Alter Menu statement adds menu items to an existing menu or removes menu items from an
existing menu.
The statement can identify the menu to be modified by specifying the name of the menu (e.g., "File")
through the menuname parameter.
If the menu to be modified is one of the standard MapInfo Pro menus, the Alter Menu statement
can identify which menu to alter by using the ID clause. The ID clause identifies the menu by a
number from 1 to 64. The following table lists the names and ID numbers of all standard MapInfo
Pro menus.
Browse M_BROWSE 8 Browse menu. Ordinarily, this only appears when a Browser window
is the active window.
Map M_MAP 9 Map menu. Ordinarily, this menu is only available when a Map
window is active.
MapBasic M_MAPBASIC 12 MapBasic menu. Available when the MapBasic window is active.
Open Web Service M_OPEN_WEBSERVICE 39 Open Web Service submenu on the File menu.
Oracle Workspace M_ORACLE_TOOLS 41 Oracle Workspace Tools submenu on the Table menu.
Tools
Tile Server Maps M_TILESERVER 45 Tile Server submenu on the File menu.
The following are shortcut menus, which appear when the user clicks with the right mouse button.
When altering a Custom menu (even if you create it with an Custom ID, such as 999), you are
required to use the Custom menuname, not the Custom ID, to alter it.
Examples
The following statement adds an item to the File menu.
In the following example, the menu item that is added contains an ID clause. The ID number (300)
can be used in subsequent Alter Menu Item statements.
The following example removes the custom item from the File menu.
The sample program, TextBox, uses a Create Menu statement to create a menu called "TextBox,"
and then issues the following Alter Menu statement to add the TextBox menu as a hierarchical
menu located on the Tools menu:
The following example adds a custom command to the Map window's shortcut menu (the menu that
appears when an MapInfo Pro user right-clicks on a Map window).
See Also:
Alter Menu Bar statement, Alter Menu Item statement, Create Menu statement, Create Menu
Bar statement
Syntax
Description
The Alter Menu Bar statement adds or removes one or more menus from the current menu bar.
The menuname parameter is a string representing the name of a menu, such as "File" or "Edit".
The menuname parameter may also refer to the name of a custom menu created by a Create Menu
statement (see example below)
Note: If the application is running on a non-English language version of MapInfo, and if the menu
names have been translated, the Alter Menu Bar statement must specify the translated
version of the menu name. However, each of MapInfo Pro's standard menus (File, Edit, etc.)
also has a menu ID, which you can use regardless of whether the menu names have been
translated. For example, specifying ID 2 always refers to the Edit menu, regardless of whether
the menu has been translated.
For a list of MapInfo Pro's standard menu names and their corresponding ID numbers, see Alter
Menu statement.
After an Alter Menu Bar Remove... statement removes a menu, MapInfo Pro ignores any hotkey
sequences corresponding to items that were on the removed menu. For example, a MapInfo Pro
user might ordinarily press Ctrl+O to bring up the File menu's Open dialog box; however, if an Alter
Menu Bar Remove statement removed the File menu, MapInfo Pro would ignore any Ctrl+O
key-presses.
Example
The following example creates a custom menu, called DataEntry, then uses an Alter Menu Bar
Add statement to add the DataEntry menu to MapInfo Pro's menu bar.
Before adding the custom menu to the menu bar, this program removes the Help menu (menu ID
7) and the Window menu (ID 6) from the menu bar. The program then adds the custom menu, the
Window menu, and the Help menu to the menu bar. This technique guarantees that the last two
menus will always be Window and Help.
See Also:
Alter Menu statement, Alter Menu Item statement, Create Menu statement, Create Menu Bar
statement, Menu Bar statement
Syntax
handler is either the name of a Sub procedure or the code for a standard MapInfo Pro command.
menu_item_id is an integer that identifies a menu item; this corresponds to the menu_item_id
parameter specified in the statement that created the menu item (Create Menu statement or Alter
Menu statement).
itemname is the new text for the menu item (may contain embedded codes).
menuname is the name of an existing menu.
Things to remember when using this command with MapInfo Pro 64-bit:
1. In MapInfo Pro 64-bit, this command is only supported for user created controls.
2. Modifying text with new shortcut would only take effect if it is not being used by any other control
in application.
3. Calling As Clause is not supported.
Description
The Alter Menu Item statement alters one or more of the items that make up the available menus.
For example, you could use the Alter Menu Item statement to check or disable (gray out) a menu
item.
The statement must either specify a handler (e.g., the name of a procedure in the same program),
or an ID clause to indicate which menu item(s) to modify. Note that it is possible for multiple, separate
menu items to call the same handler procedure. If the Alter Menu Item statement includes the name
of a handler procedure, MapInfo Pro alters all menu items that call that handler. If the statement
includes an ID clause, MapInfo Pro alters only the menu item that was defined with that ID.
The Alter Menu Item statement can only refer to a menu item ID if the statement which defined the
menu item included an ID clause. A MapBasic application cannot refer to menu item IDs created
by other MapBasic applications.
The Check clause and the Uncheck clause affect whether the item appears with a checkmark on
the menu. Note that a menu item may only be checked if it was defined as "checkable" (for example,
if the Create Map statement included a "!" as the first character of the menu item name).
The Disable clause and the Enable clause control whether the item is disabled (grayed out) or
enabled. Note that MapInfo Pro automatically enables and disables various menu items based on
the current circumstances. For example, the Close command is disabled whenever there are no
tables open. Therefore, MapBasic applications should not attempt to enable or disable standard
MapInfo Pro menu items. Similarly, although you can treat specific tools as menu items (by referencing
defines from MENU.DEF, such as M_TOOLS_RULER), you should not attempt to enable or disable
tools through the Alter Menu Item statement.
The Text clause allows you to rename a menu item.
The Calling clause specifies a handler for the menu item. If the user chooses the menu item, MapInfo
Pro calls the item's handler.
Examples
The following example creates a custom "DataEntry" menu.
The following Alter Menu Item statement renames the "Edit" item to read "Edit..."
The following statement disables both the "Delete" and the "Delete All" items, because it identifies
the handler procedure delsub, which is the handler for both menu items.
See Also:
Alter Menu statement, Alter Menu Bar statement, Create Menu statement
Syntax
Description
The Alter Object statement alters the shape, position, or graphical style of an object.
The effect of an Alter Object statement depends on whether the statement includes an Info clause,
a Node clause, or a Geography clause. If the statement includes an Info clause, MapBasic alters
the object's graphical style (e.g., the object's Pen and Brush styles). If the statement includes a
Node clause, MapBasic adds, removes, or repositions a node (this applies only to polyline or region
objects). If the statement includes a Geography clause, MapBasic alters a geographical attribute
for objects other than polylines and regions (e.g., the x- or y-coordinate of a point object).
Info clause
By issuing an Alter Object statement with an Info clause, you can reset an object's style (e.g., the
Pen or Brush). The Info clause lets you modify the same style attributes that you can query through
the ObjectInfo() function.
For example, you can determine an object's current Brush style by calling the ObjectInfo() function:
Conversely, the following Alter Object statement allows you to reset the Brush style:
Note that you use the same code (e.g., OBJ_INFO_BRUSH) in both the ObjectInfo() function and
the Alter Object statement.
The table below summarizes the values you can specify in the Info clause to perform various types
of style alterations. Note that the obj_info_code values are defined in the standard MapBasic
definitions file, MAPBASIC.DEF. Accordingly, your program should Include "MAPBASIC.DEF" if you
intend to use the Alter Object...Info statement.
OBJ_INFO_TEXTSTRING 3 Changes the text string that comprises a Text object; new_info_value
must be a string expression.
Geography clause
By issuing an Alter Object statement with a Geography clause, you can alter an object's
geographical coordinates. The Geography clause applies to all object types except for polylines
and regions. To alter the coordinates of a polyline or region object, use the Node clause (described
below) instead of the Geography clause.
The Geography clause lets you modify the same attributes that you can query through the
ObjectGeography() function. For example, you can obtain a line object's end coordinates by calling
the ObjectGeography() function:
Conversely, the following Alter Object statements let you alter the line object's end coordinates:
Note: You use the same codes (e.g., OBJ_GEO_LINEENDX) in both the ObjectGeography()
function and the Alter Object statement.
The table below summarizes the values you can specify in the Geography clause in order to perform
various types of geographic alterations. Note that the obj_geo_code values are defined in the
standard MapBasic definitions file, MAPBASIC.DEF. Your program should Include "MAPBASIC.DEF"
if you intend to use the Alter Object...Geography statement.
OBJ_GEO_ROUNDRADIUS 5 Alters the diameter of the circle that defines the rounded corner of
a Rounded Rectangle object.
Node clause
By issuing an Alter Object statement with a Node clause, you can add, remove, or reposition nodes
in a polyline or region object.
If the Node clause includes an Add sub-clause, the Alter Object statement adds a node to the
object. If the Node clause includes a Remove sub-clause, the statement removes a node. If the
Node clause includes a Set Position sub-clause, the statement repositions a node.
The Alter Object statement's Node clause is often used in conjunction with the Create Pline
statement and the Create Region statement. Create statements allow you to create new polyline
and region objects. However, Create statements are somewhat restrictive, because they force you
to state at compile time the number of nodes that will comprise the object. In some situations, you
may not know how many nodes should go into an object until run-time.
If your program will not know until run-time how many nodes should comprise an object, you can
issue a Create Pline statement or a Create Region statement which creates an "empty" object
(an object with zero nodes). Your program can then issue an appropriate number of Alter
Object...Node Add statements, to add nodes as needed.
Within the Node clause, the Position sub-clause includes two parameters, polygon_num and
node_num, that let you specify exactly which node you want to reposition or remove. The Position
sub-clause is optional when you are adding a node. The polygon_num and node_num parameters
should always be 1 (one) or greater.
The polygon_num parameter specifies which polygon in a multiple-polygon region (or which section
in a multiple-section polyline) should be modified.
Region Centroids
The Centroid of a Region can be set by using the Alter Object command with the syntax noted
below:
Note that PointObj is a point object. This differs from other values input by Alter Object Geography,
which are all scalars. A point is needed in this instance because we need two values which define
a point. The Point that is input is checked to make sure it is a valid Centroid (for example, it is inside
the region). If the Obj is not a region, or if PointObj is not a point object, or if the point is not a valid
centroid, then an error is returned.
An easy way to center an X and Y value for a centroid is as follows:
The user can also query the centroid by using the ObjectGeography() function as follows:
There are other ways to get the Centroid, including the Centroid() function, CentroidX() function,
and CentroidY() function.
OBJ_GEO_CENTROID is defined in MAPBASIC.DEF.
• Collection: By issuing an Alter Object statement with an Info clause, you can reset collection
parts (Region, Polyline or Multipoint) inside the collection object. The Info clause allows you to
modify the same attributes that you can query through the ObjectInfo() function. For example,
you can determine a collection object's region part by calling the ObjectInfo() function:
Also, the following Alter Object statement allows you to reset the region part of a collection object:
Note: You use the same code (e.g., OBJ_INFO_REGION) in both the ObjectInfo() function and
the Alter Object statement.
The Alter Object statement inserts and deletes nodes to/from Multipoint objects.
Example
Note: After using the Alter Object statement to modify an object, use an Insert statement or an
Update statement to store the object in a table.
See Also:
Create Pline statement, Create Region statement, Insert statement, ObjectGeography()
function, ObjectInfo() function, Update statement
Syntax
Description
The Alter Table statement lets you modify the structure of an open table, allowing you to add
columns, change column widths or datatypes, drop (delete) columns, rename columns, and change
column ordering.
Note: If you have edited a table, you must save or discard your edits before you can use the Alter
Table statement.
Each columntype should be one of the following: integer, SmallInt, float, decimal( size, decplaces
), char(size), date, or logical, DateTime. DateTime is an integer value stored in nine bytes: 4 bytes
for date, 5 bytes for time. Five bytes for time include: 2 for millisec, 1 for sec, 1 for min, 1 for hour.
By including an Add clause in an Alter Table statement, you can add new columns to your table.
By including a Modify clause, you can change the datatypes of existing columns. A Drop clause
lets you delete columns, while a Rename clause lets you change the names of existing columns.
The Order clause lets you specify the order of the columns. Altogether, an Alter Table statement
can have up to five clauses. Note that each of these five clauses can operate on a list of columns;
thus, with a single Alter Table statement, you can make all of the structural changes that you need
to make (see example below).
The Order clause affects the order of the columns, not the order of rows in the table. Column order
dictates the relative positions of the columns when you browse the table; the first column appears
at the left edge of a Browser window, and the last column appears at the right edge. Similarly, a
table's first column appears at the top of an Info Tool window.
If a MapBasic application issues an Alter Table statement affecting a table which has memo fields,
the memo fields will be lost. No warning will be displayed.
An Alter Table statement may cause map layers to be removed from a Map window, possibly
causing the loss of themes or cosmetic objects. If you include the Interactive keyword, MapInfo
Pro prompts the user to save themes and/or cosmetic objects (if themes or cosmetic objects are
about to be lost).
Example
In the following example, we have a hypothetical table, "gcpop.tab" which contains the following
columns: pop_88, metsize, fipscode, and utmcode. The Alter Table statement below makes several
changes to the gcpop table. First, a Rename clause changes the name of the pop_88 column to
population. Then the Drop clause deletes the metsize, fipscode, and utmcode columns. An Add
clause creates two new columns: a small (2-byte) integer column called schoolcode, and a floating
point column called federalaid. Finally, an Order clause specifies the order for the new set of columns:
the schoolcode column comes first, followed by the population column, etc.
See Also:
Add Column statement, Create Index statement, Create Map statement, Create Table statement
ApplicationDirectory$() function
Purpose
Returns a string containing the path from which the current MapBasic application is executing. You
can call this function from the MapBasic window in MapInfo Pro.
Syntax
ApplicationDirectory$()
Return Value
String expression, representing a directory path.
Description
By calling the ApplicationDirectory$() function from within a compiled MapBasic application, you
can determine the directory or folder from which the application is running. If no application is running
(e.g., if you call the function by typing into the MapBasic window), ApplicationDirectory$() returns
a null string.
To determine the directory or folder where the MapInfo Pro software is installed, call the
ProgramDirectory$() function.
Example
See Also:
ProgramDirectory$() function, ApplicationName$() function
ApplicationName$() function
Purpose
Returns a string containing the name of the current MapBasic application that is running. You can
call this function from the MapBasic window in MapInfo Pro.
Syntax
ApplicationName$()
Return Value
String expression representing the name of the MapBasic program.
Description
By calling the ApplicationName$() function from within a compiled MapBasic application, you can
determine the name of the running application. If no application is running (if you call the function
by typing into the MapBasic window), then ApplicationName$() returns an empty string.
To determine the path from which the current MapBasic application is executing call the
ApplicationDirectory$() function.
Example
See Also:
ApplicationDirectory$() function
Area() function
Purpose
Returns the geographical area of an Object. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
Return Value
Float
Description
The Area() function returns the area of the geographical object specified by obj_expr.
The function returns the area measurement in the units specified by the unit_name parameter; for
example, to obtain an area in acres, specify "acre" as the unit_name parameter. See Set Area Units
statement for the list of available unit names.
Only regions, ellipses, rectangles, and rounded rectangles have any area. By definition, the area
of a point, arc, text, line, or polyline object is zero. The Area() function returns approximate results
when used on rounded rectangles. MapBasic calculates the area of a rounded rectangle as if the
object were a conventional rectangle.
For the most part, MapInfo Pro performs a Cartesian or Spherical operation. Generally, a spherical
operation is performed unless the coordinate system is NonEarth, in which case, a Cartesian
operation is performed.
Examples
The following example shows how the Area() function can calculate the area of a single geographic
object. Note that the expression tablename.obj (as in states.obj) represents the geographical object
of the current row in the specified table.
You can also use the Area() function within the SQL Select statement, as shown in the following
example.
See Also:
ObjectLen() function, Perimeter() function, CartesianArea() function, SphericalArea() function,
Set Area Units statement
AreaOverlap() function
Purpose
Returns the area resulting from the overlap of two closed objects. You can call this function from
the MapBasic window in MapInfo Pro.
Syntax
Return Value
A float value representing the area (in MapBasic's current area units) of the overlap of the two
objects.
Restrictions
AreaOverlap() only works on closed objects. If both objects are not closed (such as points and lines),
then you may see an error message. Closed objects are objects that can produce an area, such as
regions (polygons).
See Also:
IntersectNodes() function, Overlap() function, ProportionOverlap() function, Set Area Units
statement
Asc() function
Purpose
Returns the character code for the first character in a string expression. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
Asc( string_expr )
Return Value
Integer
Description
The Asc() function returns the character code representing the first character in the string specified
by string_expr.
If string_expr is a null string, the Asc() function returns a value of zero.
Note: All MapInfo Pro environments have common character codes within the range of 32 (space)
to 126 (tilde).
On a system that supports double-byte character sets (e.g., Windows Japanese): if the first character
of string_expr is a single-byte character, Asc() returns a number in the range 0 - 255; if the first
character of string_expr is a double-byte character, Asc() returns a value in the range 256 - 65,535.
On systems that do not support double-byte character sets, Asc() returns a number in the range 0
- 255.
In Unicode versions of MapInfo Pro, this function operates in the system character set in a compatible
manner with the non-Unicode versions of MapInfo Pro.
Example
See Also:
CharVal() function, Chr$() function, Character Code Table Definitions
Asin() function
Purpose
Returns the arc-sine value of a number. You can call this function from the MapBasic window in
MapInfo Pro.
Syntax
Asin( num_expr )
Return Value
Float
Description
The Asin() function returns the arc-sine of the numeric num_expr value. In other words, Asin()
returns the angle whose sine is equal to num_expr.
The result returned from Asin() represents an angle, expressed in radians. This angle will be
somewhere between -Pi/2 and Pi/2 radians (given that Pi is approximately equal to 3.141593, and
given that Pi/2 radians represents 90 degrees).
To convert a degree value to radians, multiply that value by DEG_2_RAD. To convert a radian value
into degrees, multiply that value by RAD_2_DEG. (Note that your program will need to Include
"MAPBASIC.DEF" in order to reference DEG_2_RAD or RAD_2_DEG).
Since sine values range between one and negative one, the expression num_expr should represent
a value no larger than one (1) and no smaller than negative one (-1).
Example
Include "MAPBASIC.DEF"
Dim x, y As Float
x = 0.5
y = Asin(x) * RAD_2_DEG
See Also:
Acos() function, Atn() function, Cos() function, Sin() function, Tan() function
Ask() function
Purpose
Displays a dialog box, asking the user a yes or no (OK or Cancel) question. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Logical
Description
The Ask() function displays a dialog box, asking the user a yes-or-no question. The prompt parameter
specifies a message, such as "File already exists; do you want to continue?" While the length of
the prompt string passed to the Ask function can be approximately 2000 characters long,only the
first 299 will display in the dialog.
The dialog box contains two buttons; the user can click one button to give a Yes answer to the
prompt, or click the other button to give a No answer. The ok_text parameter specifies the name of
the Yes-answer button (e.g., "OK" or "Continue"), and the cancel_text parameter specifies the name
of the No-answer button (e.g., "Cancel" or "Stop").
If the user selects the ok_text button, the Ask() function returns TRUE. If the user clicks the
cancel_text button or otherwise cancels the dialog box (e.g., by pressing the Esc key), the Ask()
function returns FALSE. Since the buttons are limited in size, the ok_text and cancel_text strings
should be brief. If you need to display phrases that are too long to fit in small dialog box buttons,
you can use the Dialog statement instead of calling the Ask() function. The ok_text button is the
default button (the button which will be selected if the user presses Enter instead of clicking with
the mouse).
Example
See Also:
Dialog statement, Note statement, Print statement
Atn() function
Purpose
Returns the arc-tangent value of a number. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
Atn( num_expr )
Return Value
Float
Description
The Atn() function returns the arc-tangent of the numeric num_expr value. In other words, Atn()
returns the angle whose tangent is equal to num_expr. The num_expr expression can have any
numeric value.
The result returned from Atn() represents an angle, expressed in radians, in the range -Pi/2 radians
to Pi/2 radians.
To convert a degree value to radians, multiply that value by DEG_2_RAD. To convert a radian value
into degrees, multiply that value by RAD_2_DEG. (Note that your program will need to Include
"MAPBASIC.DEF" in order to reference DEG_2_RAD or RAD_2_DEG).
Example
Include "MAPBASIC.DEF"
Dim val As Float
See Also:
Acos() function, Asin() function, Cos() function, Sin() function, Tan() function
AutoLabel statement
Purpose
Draws labels in a Map window, and stores the labels in the Cosmetic layer. You can issue this
statement from the MapBasic window in MapInfo Pro.
Syntax
AutoLabel
[ Window window_id ]
[ { Selection | Layer layer_id } ]
[ Overlap [ { On | Off } ] ]
[ Duplicates [ { On | Off } ] ]
Description
The AutoLabel statement draws labels (text objects) in a Map window. Only objects that are currently
visible in the Map window are labeled. The Window clause controls which Map window is labeled.
If you omit the Window clause, MapInfo Pro draws labels in the front-most Map window. If you
specify Selection, only selected objects are labeled. If you omit both the Selection and the Layer
clause, all layers are labeled.
The Overlap clause controls whether MapInfo Pro draws labels that overlap other labels. This setting
defaults to Off (MapInfo Pro will not draw overlapping labels). To force MapInfo Pro to draw a label
for every map object, regardless of whether the labels overlap, specify Overlap On. The Duplicates
clause controls whether MapInfo Pro draws a new label for an object that has already been labeled.
This setting defaults to Off (duplicates not allowed). The AutoLabel statement uses whatever font
and position settings are in effect. Set label options by choosing the Layers command (on the HOME
tab in the Document Windows group). To control font and position settings through MapBasic,
issue a Set Map statement.
Example
See Also:
Set Map statement
Beep statement
Purpose
Makes a beeping sound. You can issue this statement from the MapBasic window in MapInfo Pro.
Syntax
Beep
Description
The Beep statement sends a sound to the speaker.
Browse statement
Purpose
Opens a new Browser window. You can issue this statement from the MapBasic window in MapInfo
Pro.
Syntax
window_width and window_height specify the size of the Browser, in paper_units. With the Into
Window clause, this represents the width and height of the frame in the Layout window. If a valid
width or height is not specified, then a value is generated for the frame.
n is a positive integer value of 1 or higher.
framename is a string representing the name for this browser embedded in a layout frame. 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.
layout_win_id is a Layout window's integer window identifier.
empty_frame_id is an emptly Layout window's integer window identifier.
Description
The Browse statement opens a Browse window to display a table. You can also use it to insert a
Browser window into a Layout window when preparing a layout. This description will use the name
Browser to mean either a Browser window in MapInfo Pro or a browser frame in a Layout window.
If the expression_list is simply an asterisk (*), the new Browser includes all fields in the table.
Alternately, the expression_list clause can consist of a comma-separated list of expressions, each
of which defines one column that is to appear in the Browser. Expressions in the list can contain
column names, operators, functions, and variables. Each column's name is derived from the
expression that defines the column. Thus, if a column is defined by the expression population /
area(obj, "acre"), that expression will appear on the top row of the Browser, as the column name.
To assign an alias to an expression, follow the expression with a string; see the example below.
An optional Position clause lets you specify where on the screen or in a layout to display the
Browser. The x coordinate specifies the distance (in paper units) from the left edge of the MapInfo
Pro application window to the left edge of the Browser window, or from the left edge of the Layout
window to the left edge of a browser frame. For details about paper units, see Set Paper Units
statement. The y coordinate specifies the distance from the top of the window down to the top of
the Browser.
The optional Width and Height clauses specify the size of the Browser window, in paper units. If
no Width and Height clauses are provided, MapInfo Pro assigns the Browser a default size that
depends on the table in question. For a Browser window, its height will be one quarter of the screen
height, unless the table does not have enough rows to fill a Browser window that large; and the
Browser width will depend on the widths of the fields in the table.
The optional Width and Height clauses specify the size of the Browser, in paper units. If no Width
and Height clauses are provided, MapInfo Pro assigns the Browser a default size that depends on
the table in question. For a Browser window, its height will be one quarter of the screen height,
unless the table does not have enough rows to fill a Browser window that large; and the Browser
window's width will depend on the widths of the fields in the table.
If the Browse statement includes the optional Max keyword, then the resulting Browser is maximized,
taking up all of the screen space available to MapInfo Pro or the entire canvas in a Layout Desinger
window. Conversely, if the Browse statement includes the Min keyword, the Browser is minimized
immediately.
The Row clause dictates which row of the table should appear at the top of the Browser. If the
Browse statement does not include a Row clause, the first row of the table will be the top row in
the Browser.
Similarly, the Column clause dictates which of the table's columns should appear at the left edge
of the Browser. If the Browse statement does not include a Column clause, the table's first column
will appear at the left edge of the Browser.
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.
Priority 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.
The Into Window clause creates a new frame within an existing Layout window.
Use the ID clause to insert open tables into an empty layout frame. The frame properties already
set for the empty frame are retained (pen, brush, position, size, name, and z-order). An error results
when the:
• From Window ID is not a map or browser: 1696 "Error: Expecting Map or Browser Window."
• Frame ID is not empty: 1698 "Layout frame ^0 must be empty."
• From Window does not close: 1697 "Unable to clone Window into empty frame."
• Map legends does not clone: 1708 "Unable to clone Legends for Map frame."
The following example creates a browser for the open table called World and inserts it into the empty
frame in the Layout window.
To reuse a frame after it has been filled with content it needs to be emptied, see the Set Designer
Frame statement. This leaves behind an empty frame of the same size and position as the content
it just contained, and retains the name currently assigned to it.
Example
The following example opens the World table and displays all columns from the table in a Browser
window.
The next example specifies exactly which column expressions from the World table should be
displayed in the Browser.
The resultant Browser has three columns. The first two columns represent data as it is stored in the
World table, while the third column is derived. Through the third expression, MapBasic divides the
population of each country record with the geographic area of the region associated with that record.
The derived column expression has an alias ("Density") which appears on the top row of the Browse
window.
See Also:
FrontWindow() function, Set Browse statement, Set Designer Frame statement, Set Paper
Units statement, Set Window statement, WindowID() function
BrowserInfo() function
Purpose
Returns information about a Browser window, such as: the total number of rows or columns in the
Browser window; or the row number, column number, or value contained in the current cell. You
can call this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Float, logical, or string depending on the attribute parameter.
Description
The BrowserInfo() function returns information about a Browser window. The function does not apply
to the Redistricter window.
The window_id parameter specifies which Browser 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.
There are several attributes that BrowserInfo() returns about any given Browser window. The attribute
parameter tells the BrowserInfo () function what Browser window statistic to return. The attribute
parameter should be one of the codes from the following table; codes are defined in MAPBASIC.DEF.
BROWSER_INFO_CURRENT_ROW 3 The row number of the current cell in the Browser window. Row
numbers start at one (1).
BROWSER_INFO_CURRENT_COLUMN 4 The column number of the current cell in the Browser window.
Column numbers start at zero (0).
BROWSER_INFO_CURRENT_CELL_VALUE 5 The value contained in the current cell in the Browser window.
Error Conditions
ERR_BAD_WINDOW (590) error generated if parameter is not a valid window number.
ERR_FCN_ARG_RANGE (644) error generated if an argument is outside of the valid range.
ERR_WANT_BROWSER_WIN (312) error generated if window id is not a Browser window.
See Also:
Brush clause
Purpose
Specifies a fill style for graphic objects. You can use this clause in the MapBasic window in MapInfo
Pro.
Syntax
Brush brush_expr
brush_expr is a Brush expression, such as MakeBrush( pattern, fgcolor, bgcolor ). (See MakeBrush(
) function for more information.) or a Brush variable.
Description
The Brush clause specifies a brush style―in other words, a set of color and pattern settings that
dictate the appearance of a filled object, such as a circle or rectangle. Brush is a clause, not a
complete MapBasic statement. Various object-related statements, such as Create Ellipse statement,
allow you to specify a brush value. The keyword Brush may be followed by an expression which
evaluates to a Brush value. This expression can be a Brush variable:
Brush br_var
With some MapBasic statements (e.g., Set Map statement), the keyword Brush can be followed
immediately by the three parameters that define a Brush style (pattern, foreground color, and
background color) within parentheses:
Some MapBasic statements take a Brush expression as a parameter (e.g., the name of a Brush
variable), rather than a full Brush clause (the keyword Brush followed by the name of a Brush
variable). The Alter Object statement is one example.
The following table summarizes the three components (pattern, foreground color, background color)
that define a Brush:
Component Description
Component Description
foreground color Integer RGB color value; see RGB( ) function. The definitions file,
MAPBASIC.DEF, includes Define statements for BLACK, WHITE,
RED, GREEN, BLUE, CYAN, MAGENTA, and YELLOW.
To specify a transparent background, use pattern 3 or larger, and omit the background color from
the Brush clause. For example, specify Brush(5, BLUE) to see thin blue stripes with no background
fill color. Omitting the background parameter is like clearing the Background check box in MapInfo
Pro's Region Style dialog box.
To specify a transparent background when calling the MakeBrush( ) function specify -1 as the
background color.
The available patterns appear as follows. Pattern 2 produces a solid fill; pattern 1 produces no fill.
For a comprehensive list of fill patterns, see the MapInfo Pro Help―launch MapInfo Pro and open
the Help System and search for MapInfo Pro Fill Pattern Table.
See Also:
CurrentBrush( ) function, MakeBrush( ) function, Pen clause, Font clause, Symbol clause
Buffer() function
Purpose
Returns a region object that represents a buffer region (the area within a specified buffer distance
of an existing object). You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Returns a region object.
Description
The Buffer() function returns a region representing a buffer.
The Buffer() function operates on one single object at a time. To create a buffer around a set of
objects, use the Create Object statement As Buffer. The object will be created using the current
MapBasic coordinate system. The method used to calculate the buffer depends on the coordinate
system. If it is NonEarth, then a Cartesian method will be used. Otherwise, a spherical method will
be used.
Example
The following program creates a line object, then creates a buffer region surrounding the line. The
buffer region extends ten miles in all directions from the line.
See Also:
Create Object statement, Set Buffer Version statement
ButtonPadInfo() function
Purpose
Returns information about a ButtonPad. You can call this function from the MapBasic window in
MapInfo Pro.
Syntax
pad_name is a string representing the name of an existing ButtonPad; use "Main", "Drawing", "Tools"
or "Standard" to query the standard pads, or specify the name of a custom pad.
attribute is a code indicating which information to return; see table below.
Return Value
Depends on the attribute parameter specified.
Description
The attribute parameter specifies what to return. Codes are defined in MAPBASIC.DEF
BTNPAD_INFO_FLOATING 1 Logical. TRUE means the pad is floating, FALSE means the pad is
docked.
BTNPAD_INFO_DOCK_POSITION 7 Returns the position of the button pad as Floating, Left, Top, Right
or Bottom. Use for floating toolbars as an alternative to
BTNPAD_INFO_FLOATING. Returns:
• BTNPAD_INFO_DOCK_NONE (0)
• BTNPAD_INFO_DOCK_LEFT (1)
• BTNPAD_INFO_DOCK_TOP (2)
• BTNPAD_INFO_DOCK_RIGHT (3)
• BTNPAD_INFO_DOCK_BOTTOM (4)
Example
Include "mapbasic.def"
If ButtonPadInfo("Main", BTNPAD_INFO_FLOATING) Then
'...then the Main pad is floating; now let's dock it.
Alter ButtonPad "Main" ToolbarPosition(0,0) Fixed
End If
See Also:
Alter ButtonPad statement
Call statement
Purpose
Calls a sub procedure or an external routine (DLL, XCMD).
Restrictions
You cannot issue a Call statement through the MapBasic window.
Syntax
Description
The Call statement calls a procedure. The procedure is usually a conventional MapBasic sub
procedure (defined through the Sub...End Sub statement). Alternately, a program running under
MapInfo Pro can call a Windows Dynamic Link Library (DLL) routine through the Call statement.
When a Call statement calls a conventional MapBasic procedure, MapBasic begins executing the
statements in the specified sub procedure, and continues until encountering an End Sub or an Exit
Sub statement. At that time, MapBasic returns from the sub procedure, then executes the statements
following the Call statement. The Call statement can only access sub procedures which are part of
the same application.
A MapBasic program must issue a Declare Sub statement to define the name and parameter list
of any procedure which is to be called. This requirement is independent of whether the procedure
is a conventional MapBasic Sub procedure, a DLL procedure or an XCMD.
Parameter Passing
Sub procedures may be defined with no parameters. If a particular sub procedure has no parameters,
then calls to that sub procedure may appear in either of the following forms:
Call subroutine
or
Call subroutine()
By default, each sub procedure parameter is defined "by reference." When a sub procedure has a
by-reference parameter, the caller must specify the name of a variable to pass as the parameter.
If the procedure then alters the contents of the by-reference parameter, the caller's variable is
automatically updated to reflect the change. This allows the caller to examine the results returned
by the sub procedure.
Alternately, any or all sub procedure parameters may be passed "by value" if the keyword ByVal
appears before the parameter name in the Sub and Declare Sub declarations. When a parameter
is passed by value, the sub procedure receives a copy of the value of the parameter expression;
thus, the caller can pass any expression, rather than having to pass the name of a variable.
A sub procedure can take an entire array as a single parameter. When a sub procedure expects
an array as a parameter, the caller should specify the name of an array variable, without parentheses.
Example
In the following example, the sub procedure Cube cubes a number (raises the number to the power
of three), and returns the result. The sub procedure takes two parameters; the first parameter
contains the number to be cubed, and the second parameter passes the results back to the caller.
See Also:
Declare Sub statement, Exit Sub statement, Global statement, Sub...End Sub statement
CartesianArea() function
Purpose
Returns the area as calculated in a flat, projected coordinate system using a Cartesian algorithm.
You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Float
Description
The CartesianArea() function returns the Cartesian area of the geographical object specified by
obj_expr.
The function returns the area measurement in the units specified by the unit_name parameter; for
example, to obtain an area in acres, specify "acre" as the unit_name parameter. See the Set Area
Units statement for the list of available unit names.
The CartesianArea() function will always return the area using a cartesian algorithm. A value of -1
will be returned for data that is in a Latitude/Longitude since the data is not projected.
Only regions, ellipses, rectangles, and rounded rectangles have any area. By definition, the
CartesianArea() of a point, arc, text, line, or polyline object is zero. The CartesianArea() function
returns approximate results when used on rounded rectangles. MapBasic calculates the area of a
rounded rectangle as if the object were a conventional rectangle.
Examples
The following example shows how the CartesianArea() function can calculate the area of a single
geographic object. Note that the expression tablename.obj (as in states.obj) represents the
geographical object of the current row in the specified table.
You can also use the CartesianArea() function within the Select statement, as shown in the
following example.
See Also:
Area() function, SphericalArea() function
CartesianBuffer() function
Purpose
Returns a region object that represents a buffer region (the area within a specified buffer distance
of an existing object). You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Region Object
Description
The CartesianBuffer() function returns a region representing a buffer and operates on one single
object at a time.
To create a buffer around a set of objects, use the Create Object statement As Buffer. If width is
negative, and the object is a linear object (line, polyline, arc) or a point, then the absolute value of
width is used to produce a positive buffer.
The CartesianBuffer() function calculates the buffer by assuming the object is in a flat projection
and using the width to calculate a cartesian distance calculated buffer around the object.
If the inputobject is in a Latitude/Longitude Projection, then Spherical calculations will be used
regardless of the Buffer function used.
Example
The following program creates a line object, then creates a buffer region that extends 10 miles
surrounding the line.
See Also:
Buffer() function, Creating Map Objects, Set Buffer Version statement
CartesianConnectObjects() function
Purpose
Returns an object representing the shortest or longest distance between two objects. You can call
this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
This statement returns a single section, two-point Polyline object representing either the closest
distance (min == TRUE) or farthest distance (min == FALSE) between object1 and object2.
Description
One point of the resulting Polyline object is on object1 and the other point is on object2. Note that
the distance between the two input objects can be calculated using the ObjectLen() function. If
there are multiple instances where the minimum or maximum distance exists (e.g., the two points
returned are not uniquely the shortest distance and there are other points representing "ties") then
these functions return one of the instances. There is no way to determine if the object returned is
uniquely the shortest distance.
CartesianConnectObjects() returns a Polyline object connecting object1 and object2 in the shortest
(min == TRUE) or longest (min == FALSE) way using a cartesian calculation method. If the calculation
cannot be done using a cartesian distance method (e.g., if the MapBasic Coordinate System is
Lat/Long), then this function will produce an error.
CartesianDistance() function
Purpose
Returns the distance between two locations. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
Return Value
Float
Description
The CartesianDistance() function calculates the Cartesian distance between two locations. It returns
the distance measurement in the units specified by the unit_name parameter; for example, to obtain
a distance in miles, specify "mi" as the unit_name parameter. See Set Distance Units statement
for the list of available unit names.
The CartesianDistance() function always returns a value using a cartesian algorithm. A value of
-1 is returned for data that is in a Latitude/Longitude coordinate system, since Latitude/Longitude
data is not projected and not cartesian.
The x- and y-coordinate parameters must use MapBasic's current coordinate system. By default,
MapInfo Pro expects coordinates to use a Latitude/Longitude coordinate system. You can reset
MapBasic's coordinate system through the Set CoordSys statement.
Example
See Also:
Math Functions, CartesianDistance() function, Distance() function
CartesianObjectDistance() function
Purpose
Returns the distance between two objects. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
Return Value
Float
Description
CartesianObjectDistance() returns the minimum distance between object1 and object2 using a
cartesian calculation method with the return value in unit_name. If the calculation cannot be done
using a cartesian distance method (e.g., if the MapBasic Coordinate System is Lat/Long), then this
function will produce an error.
CartesianObjectLen() function
Purpose
Returns the geographic length of a line or polyline object. You can call this function from the
MapBasic window in MapInfo Pro.
Syntax
Return Value
Float
Description
The CartesianObjectLen() function returns the length of an object expression. Note that only line
and polyline objects have length values greater than zero; to measure the circumference of a
rectangle, ellipse, or region, use the Perimeter() function.
The CartesianObjectLen() function will always return a value using a cartesian algorithm. A value
of -1 will be returned for data that is in a Latitude/Longitude coordinate system, since
Latitude/Longitude data is not projected and not cartesian.
The CartesianObjectLen() function returns a length measurement in the units specified by the
unit_name parameter; for example, to obtain a length in miles, specify "mi" as the unit_name
parameter. See the Set Distance Units statement for the list of valid unit names.
Example
See Also:
CartesianOffset() function
Purpose
Returns a copy of the input object offset by the specified distance and angle using a Cartesian
DistanceType. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Object
Description
This function produces a new object that is a copy of the input object offset by distance along angle
(in degrees with horizontal in the positive X-axis being 0 and positive being counterclockwise). The
unit string, similar to that used for ObjectLen() function or Perimeter() function, is the unit for the
distance value. The DistanceType used is Cartesian. If the coordinate system of the input object is
Lat/Long, an error will occur, since Cartesian DistanceTypes are not valid for Lat/Long. This is
signified by returning a NULL object. The coordinate system used is the coordinate system of the
input object.
There are some considerations for Spherical measurements that do not hold for Cartesian
measurements. If you move an object that is in Lat/Long, the shape of the object remains the same,
but the area of the object will change. This is because you are picking one offset delta in degrees,
and the actual measured distance for a degree is different at different locations.
For the Offset functions, the actual offset delta is calculated at some fixed point on the object (e.g.,
the center of the bounding box), and then that value is converted from the input units into the
coordinate system's units. If the coordinate system is Lat/Long, the conversion to degrees uses the
fixed point. The actual converted distance measurement could vary at different locations on the
object. The distance from the input object and the new offset object is only guaranteed to be exact
at the single fixed point used.
Example
See Also:
CartesianOffsetXY() function
CartesianOffsetXY() function
Purpose
Returns a copy of the input object offset by the specified X and Y offset values using a cartesian
DistanceType. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
Object
Description
This function produces a new object that is a copy of the input object offset by xoffset along the
X-axis and yoffset along the Y-axis. The unit string, similar to that used for ObjectLen() function
or Perimeter() function, is the unit for the distance values. The DistanceType used is Cartesian.
If the coordinate system of the input object is Lat/Long, an error will occur, since Cartesian
DistanceTypes are not valid for Lat/Long. This is signified by returning a NULL object. The coordinate
system used is the coordinate system of the input object.
There are some considerations for Spherical measurements that do not hold for Cartesian
measurements. If you move an object that is in Lat/Long, the shape of the object remains the same,
but the area of the object will change. This is because you are picking one offset delta in degrees,
and the actual measured distance for a degree is different at different locations.
For the Offset functions, the actual offset delta is calculated at some fixed point on the object (e.g.,
the center of the bounding box), and then that value is converted from the input units into the
coordinate system's units. If the coordinate system is Lat/Long, the conversion to degrees uses the
fixed point. The actual converted distance measurement could vary at different locations on the
object. The distance from the input object and the new offset object is only guaranteed to be exact
at the single fixed point used.
Example
See Also:
CartesianOffset() function
CartesianPerimeter() function
Purpose
Returns the perimeter of a graphical object. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
Return Value
Float
Description
The CartesianPerimeter() function calculates the perimeter of the obj_expr object. The Perimeter()
function is defined for the following object types: ellipses, rectangles, rounded rectangles, and
polygons. Other types of objects have perimeter measurements of zero.
The CartesianPerimeter() function will always return a value using a Cartesian algorithm. A value
of -1 will be returned for data that is in a Latitude/Longitude coordinate system, since
Latitude/Longitude data is not projected and not Cartesian.
The CartesianPerimeter() function returns a length measurement in the units specified by the
unit_name parameter; for example, to obtain a length in miles, specify "mi" as the unit_name
parameter. See the Set Distance Units statement for the list of valid unit names.
CartesianPerimeter() returns approximate results when used on rounded rectangles. MapBasic
calculates the perimeter of a rounded rectangle as if the object were a conventional rectangle.
Example
The following example shows how you can use the CartesianPerimeter() function to determine the
perimeter of a particular geographic object.
You can also use the CartesianPerimeter() function within the Select statement. The following
Select statement extracts information from the States table, and stores the results in a temporary
table called Results. Because the Select statement includes the CartesianPerimeter() function,
the Results table will include a column showing each state's perimeter.
See Also:
CartesianPerimeter() function, SphericalPerimeter() function, Perimeter() function
Centroid() function
Purpose
Returns the centroid (center point) of an object. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
Centroid( obj_expr )
Return Value
Point object
Description
The Centroid() function returns a point object, which is located at the centroid of the specified
obj_expr object. A region's centroid does not represent its center of mass. Instead, it represents the
location used for automatic labeling, geocoding, and placement of thematic pie and bar charts. If
you edit a map in reshape mode, you can reposition region centroids by dragging them.
If the obj_expr parameter represents a point object, the Centroid() function returns the position of
the point. If the obj_expr parameter represents a line object, the Centroid() function returns the
point midway between the ends of the line.
If the obj_expr parameter represents a polyline object, the Centroid() function returns a point located
at the mid point of the middle segment of the polyline.
If the obj_expr parameter represents any other type of object, the Centroid() function returns a point
located at the true centroid of the original object. For rectangle, arc, text, and ellipse objects, the
centroid position is halfway between the upper and lower extents of the object, and halfway between
the left and right extents. For region objects, however, the centroid position is always on the object
in question, and therefore may not be located halfway between the object's extents.
Example
See Also:
Alter Object statement, CentroidX() function, CentroidY() function
CentroidX() function
Purpose
Returns the x-coordinate of the centroid of an object. You can call this function from the MapBasic
window in MapInfo Pro.
Syntax
CentroidX( obj_expr )
Return Value
Float
Description
The CentroidX() function returns the X coordinate (e.g., Longitude) component of the centroid of
the specified object. See the Centroid() function for a discussion of what the concept of a centroid
position means with respect to different types of graphical objects (lines vs. regions, etc.).
The coordinate information is returned in MapBasic's current coordinate system; by default, MapBasic
uses a Longitude/Latitude coordinate system. The Set CoordSys statement allows you to change
the coordinate system used.
Examples
The following example shows how the CentroidX() function can calculate the longitude of a single
geographic object.
Dim x As Float
Open Table "world"
Fetch First From world
x = CentroidX(world.obj)
You can also use the CentroidX() function within the Select statement. The following Select
statement extracts information from the World table, and stores the results in a temporary table
called Results. Because the Select statement includes the CentroidX() function and the CentroidY()
function, the Results table will include columns which display the longitude and latitude of the
centroid of each country.
See Also:
Centroid() function, CentroidY() function, Set CoordSys statement
CentroidY() function
Purpose
Returns the y-coordinate of the centroid of an object. You can call this function from the MapBasic
window in MapInfo Pro.
Syntax
CentroidY( obj_expr )
Return Value
Float
Description
The CentroidY() function returns the Y-coordinate (e.g., latitude) component of the centroid of the
specified object. See the Centroid() function for a discussion of what the concept of a centroid
position means, with respect to different types of graphical objects (lines vs. regions, etc.).
The coordinate information is returned in MapBasic's current coordinate system; by default, MapBasic
uses a Longitude/Latitude coordinate system. The Set CoordSys statement allows you to change
the coordinate system used.
Example
Dim y As Float
Open Table "world"
Fetch First From world
y = CentroidY(world.obj)
See Also:
Centroid() function, CentroidX() function, Set CoordSys statement
CharSet clause
Purpose
Specifies which character set MapBasic uses for interpreting character codes.
Note: See the MapInfo Pro User Guide for changes affecting this clause.
Syntax
CharSet char_set
char_set is a string that identifies the name of a character set; see table below.
Description
The CharSet clause specifies which character set MapBasic should use when reading or writing
files or tables. Note that CharSet is a clause, not a complete statement. Various file-related
statements, such as the Open File statement, can incorporate optional CharSet clauses.
if Windows is configured to use a different character set, character code 176 may represent a
different character.
Call SystemInfo(SYS_INFO_CHARSET) to determine the character set in use at run-time.
"WindowsJapanese"
"WindowsKorean"
"CodePage857"
Note: You never need to specify a CharSet clause in an Open Table statement. Each table's
.TAB file contains information about the character set used by the table. When opening a
table, MapInfo Pro reads the character set information directly from the .TAB file, then
automatically performs any necessary character translations.
Specify "Utf-8" for a workspace character set or Native Extended (NativeX) format table character
set to allow characters from any language to be represented. It can also be used when importing,
opening or registering a non-native table.
To force MapInfo Pro to save a table in a specific character set, include a CharSet clause in the
Commit Table statement.
See Also:
Commit Table statement, Create Table statement, Export statement, Open File statement,
Register Table statement, Character Code Table Definitions
ChooseProjection$() function
Purpose
Displays the Choose Projection dialog box and returns the coordinate system selected by the user.
You can call this function from the MapBasic window in MapInfo Pro.
Syntax
initial_coordsys is a string value in the form of a CoordSys clause. It is used to set which coordinate
system is selected when the dialog box is first displayed. If initial_coordsys is empty or an invalid
CoordSys clause, then the default Longitude/Latitude coordinate system is used as the initial
selection.
get_bounds is a logical value that determines whether the users is prompted for boundary values
when a non-earth projection is selected. If get_bounds is true then the boundary dialog box is
displayed. If false, then the dialog box is not displayed and the default boundary is used.
Description
This function displays the Choose Projection dialog box and returns the selected coordinate system
as a string. The returned string is in the same format as the CoordSys clause. Use this function if
you wish to allow the user to set a projection within your application.
Example
See Also:
MapperInfo() function
CharVal() function
Purpose
Returns the character code for the first character in a string expression. This function is the Unicode
corollary of the Asc() function, so that the return value maps to the Unicode character set encoding
of the string expression (string_expr), rather than the system character set mapping. You can call
this function from the MapBasic window in MapInfo Pro.
Syntax
CharVal( string_expr )
Return Value
Integer
Description
The CharVal() function returns the character code representing the first character in the string
specified by the string expression, string_expr. If string_expr is a null string, then CharVal() returns
a value of zero.
Note: Except for the character encoding mapping, the usage and behavior of CharVal() is the
same as Asc() function.
CharVal() is only applicable for Unicode versions of MapInfoPro and returns a value of zero for
non-Unicode versions of MapInfo Pro.
Example
The following example displays the corresponding Unicode encoding for the character, which will
be 8364, 1587, and 24330:
See Also:
Asc() function, ChrU$() function, Character Code Table Definitions
Chr$() function
Purpose
Returns a one-character string corresponding to a specified character code. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
Chr$( num_expr )
num_expr is an integer value from 0 to 255 (or, if a double-byte character set is in use, from 0 to
65,535), inclusive.
Return Value
String
Description
The Chr$() function returns a string, one character long, based on the character code specified in
the num_expr parameter. On most systems, num_expr should be a positive integer value between
0 and 255. On systems that support double-byte character sets (e.g., Windows Japanese), num_expr
can have a value from 0 to 65,535.
Note: All MapInfo Pro environments have common character codes within the range of 32 (space)
to 126 (tilde).
In Unicode versions of MapInfo Pro, this function operates in the system character set in a compatible
manner with the non-Unicode versions of MapInfo Pro.
Error Conditions
ERR_FCN_ARG_RANGE (644) error is generated if an argument is outside of the valid range.
Example
See Also:
Asc() function, ChrU$() function, Character Code Table Definitions
ChrU$() function
Purpose
Returns a one-character string corresponding to a specified character code. This function is the
Unicode corollary of the Chr$() function, so that the num_expr encoding maps to the Unicode
character codes rather than the system environment character codes. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
ChrU$( num_expr )
Return Value
String
Description
The ChrU$() function returns a string, one character long, based on the character code specified
in the num_expr parameter.
Note: Except for the character encoding mapping, the usage and behavior of ChrU$() is the same
as Chr$(). ChrU$() is only applicable for Unicode version of MapInfo Pro and returns a
[space] character in non-Unicode MapInfo Pro.
Example
The following example displays the Unicode character "€", the Unicode Arabic character ""س, and
the Unicode Traditional Chinese character " ":
Note ChrU$(8364)
Note ChrU$(1587)
Note ChrU$(24330)
See Also:
CharVal() function, Chr$() function, Character Code Table Definitions
Syntax
Description
If a MapBasic application issues a Close All statement, and the affected table has edits pending
(the table has been modified but the modifications have not yet been saved to disk), the edits will
be discarded before the table is closed. No warning will be displayed. If you do not want to discard
pending edits, use the optional Interactive clause to prompt the user to save or discard changes.
See Also:
Close Table statement
Syntax
connection_handle is an integer expression representing the value returned from the Open
Connection statement.
Description
The Close Connection statement closes the specified connection using the connection handle that
is returned from an Open Connection statement. Any service specific properties associated with
the connection are lost.
See Also:
Open Connection statement
Syntax
Description
The Close File statement closes a file which was opened through the Open File statement.
Note: The Open File statement and Close File statement operate on files in general, not on
MapInfo Pro tables. MapBasic provides a separate set of statements (e.g., Open Table
statement) for manipulating MapInfo tables.
Example
See Also:
Open File statement
Syntax
Description
The Close Table statement closes an open table. To close all tables, use the Close All statement.
If a table is displayed in one or more Grapher or Browser windows, those windows disappear
automatically when the table is closed. If the Close Table statement closes the only table in a Map
window, the window closes. If you use the Close Table statement to close a linked table that has
edits pending, MapInfo Pro keeps the edits pending until a later session.
Saving Edits
If you omit the optional Interactive keyword, MapBasic closes the table regardless of whether the
table has unsaved edits; any unsaved edits are discarded. If you include the Interactive keyword,
and if the table has unsaved edits, MapBasic displays a dialog box allowing the user to save or
discard the edits or cancel the close operation.
To guarantee that pending edits are discarded, omit the Interactive keyword or issue a Rollback
statement before calling Close Table. To guarantee that pending edits are saved, issue a Commit
Table statement before the Close Table statement. To determine whether a table has unsaved
edits, call the TableInfo() function( table, TAB_INFO_EDITED) function.
Examples
See Also:
Close All statement, Commit Table statement, Open Table statement, Rollback statement,
TableInfo() function
Syntax
window_spec is a window name (e.g., Ruler), a window code (e.g., WIN_RULER), or an integer
window identifier.
Description
The Close Window statement closes or hides a MapInfo Pro window.
To close a document window (Map, Browser, Layout, Graph), specify an integer window identifier
as the window_spec parameter. You can obtain integer window identifiers through the FrontWindow()
function and the WindowID() function.
To close a special MapInfo Pro window, specify one of the window names from the table below as
the window_spec parameter. You can identify a special window by name (e.g., Ruler) or by code
(e.g., WIN_RULER).
To close an adornment window, specify the window ID of the adornment as determined by the
MapperInfo() function.
The following table lists the available window_spec values:
TableList The Table List window (WIN_TABLE_LIST). In an integrated mapping application, this
refers to the modal version.
Note: The window IDs for Table List, Layer Control, and Move Map To windows are ignored by
the Set Window statement, WindowInfo() function, and WindowID() function.
Example
See Also:
Open Window statement, Print statement, Set Window statement
ColumnInfo() function
Purpose
Returns information about a column in an open table. You can call this function from the MapBasic
window in MapInfo Pro.
Syntax
Return Value
Depends on the attribute parameter specified.
Description
The ColumnInfo() function returns information about one column in an open table.
The function's first parameter specifies either the name or the number of an open table. The second
parameter specifies which column to query. The attribute parameter dictates which of the column's
attributes the function should return. The attribute parameter can be any value from this table.
If the ColumnInfo() function call specifies COL_INFO_TYPE as its attribute parameter, MapBasic
returns one of the values from the table below:
COL_TYPE_CHAR 1 Character.
COL_TYPE_DATE 5 Date.
COL_TYPE_GRAPHIC 7 special column type Obj; this represents the graphical objects
attached to the table.
COL_TYPE_TIME 37 Time.
COL_TYPE_DATETIME 38 DateTime.
The codes listed in both of the above tables are defined in the standard MapBasic definitions file,
MAPBASIC.DEF. Your program must include "MAPBASIC.DEF" if you intend to reference these
codes.
Error Conditions
ERR_TABLE_NOT_FOUND (405) error generated if the specified table is not available.
ERR_FCN_ARG_RANGE (644) error generated if an argument is outside of the valid range.
Example
Include "MAPBASIC.DEF"
Dim s_col_name As String, i_col_type As SmallInt
Open Table "world"
s_col_name = ColumnInfo("world","col1",COL_INFO_NAME)
i_col_type = ColumnInfo("world","col1",COL_INFO_TYPE)
See Also:
NumCols() function, TableInfo() function
Combine() function
Purpose
Returns a region or polyline representing the union of two objects. The objects cannot be Text
objects. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
object1, object2 are two object expressions; both objects can be closed (e.g., a region and a circle),
or both objects can be linear (e.g., a line and a polyline)
Return Value
An object that is the union of object1 and object2.
Description
The Combine() function returns an object representing the geographical union of two object
expressions. The union of two objects represents the entire area that is covered by either object.
The Combine() function has been updated to allow heterogeneous combines, and to allow Points,
MultiPoints, and Collections as input objects. Previously, both objects had to be either linear objects
(Lines, Polylines, or Arcs) and produce Polylines as output; or both input objects had to be closed
(Regions, Rectangles, Rounded Rectangles, or Ellipses) and produce Regions as output.
Heterogeneous combines are not allowed, as are combines containing Point, MultiPoint and Collection
objects. Text objects are still not allowed as input to Combine().
MultiPoint and Collection objects, introduced in MapInfo Pro 6.5, extend the Combine operation.
The following table details the possible combine options available and the output results:
The results returned by Combine() are similar to the results obtained by choosing MapInfo Pro's
Combine command (on the SPATIAL tab), except that the Combine command modifies the original
objects; the Combine() function does not alter the object1 or object2 expressions. Also, the
Combine() function does not perform data aggregation.
The object returned by the Combine() function retains the styles (e.g., color) of the object1 parameter
when possible. Collection objects produced as output will get those portions of style that are possible
from object1, and the remaining portions of style from objects2. For example, if object1 is a Region
and object2 is a Polyline, then the output collection will use the brush and border pen of object1 for
the Region style contained in the collection, and the pen from object2 for the Polyline style in the
collection.
See Also:
Brush clause, Objects Combine statement, Pen clause, Set Combine Version statement
CommandInfo() function
Purpose
Returns information about recent events. You can call this function from the MapBasic window in
MapInfo Pro.
Syntax
CommandInfo( attribute )
Return Value
Logical, float, integer, or string, depending on circumstances.
Description
The CommandInfo() function returns information about recent events that affect MapInfo Pro―for
example, whether the "Selection" table has changed, where the user clicked with the mouse, or
whether it was a simple click or a Shift+click.
CMD_INFO_DLG_OK 1 Logical value: TRUE if the user dismissed a custom dialog box by
clicking OK; FALSE if user canceled by clicking Cancel, pressing
Esc. (This call is only valid following a Dialog statement.)
CMD_INFO_MENUITEM 8 Integer value, representing the ID of the menu item the user chose.
This call is only valid within the handler procedure of a custom menu
item.
CMD_INFO_SELTYPE 1
1 if one row was added to the selection;
2 if one row was removed from the selection;
3 if multiple rows were added to the selection;
4 if multiple rows were de-selected.
CMD_INFO_ROWID 2 Integer value: The number of the row that was selected or
de-selected (only applies if a single row was selected or
de-selected).
CMD_INFO_MSG 1000 String value, representing the execute string or the item name sent
to MapInfo Pro by a client program. For details, see
RemoteMsgHandler procedure, RemoteQueryHandler() function,
or RemoteMapGenHandler procedure.
CMD_INFO_TASK_SWITCH 1 Integer value, indicating whether MapInfo Pro just became the active
application or just stopped being the active application. The return
value matches one of these codes: SWITCHING_INTO_MI Pro (If
MapInfo Pro received the focus) SWITCHING_OUT_OF_MapInfo
Pro (If MapInfo Pro lost the focus).
CMD_INFO_FIND_RC 3 Integer value, indicating whether the Find statement found a match.
CMD_INFO_FIND_ROWID 4 Integer value, indicating the Row ID number of the row that was
found.
CMD_INFO_SHIFT 3 Logical value: TRUE if the user held down the Shift key while
clicking.
CMD_INFO_CTRL 4 Logical value: TRUE if the user held down the Ctrl key while clicking.
CMD_INFO_X2 5 x-coordinate of the spot where the user released the mouse button.
This only applies if the toolbutton was defined with a draw mode
that allows dragging, e.g., DM_CUSTOM_LINE.
CMD_INFO_Y2 6 y-coordinate of the spot where the user released the mouse button.
CMD_INFO_TOOLBTN 7 Integer value, representing the ID of the button the user clicked
* The CommandInfo() function ignores any clicks made in the top-left corner of a Browser
window―above the select column and to the left of the column headers. It also ignores clicks made
beyond the last column or row.
Hotlink Support
MapBasic applications launched via the Hotlink Tool can use the CommandInfo() function to obtain
information about the object that was activated. The following is a table of the attributes that can be
queried:
CMD_INFO_HL_ROWID 19 ID of the table row corresponding to the map object or browser row.
CMD_INFO_HL_LAYER_ID 20 Layer ID, if the program was launched from a map window.
See Also:
FrontWindow() function, SelectionInfo() function, Set Command Info statement, WindowInfo()
function
an Interactive parameter to allow you to specify indeterminate types in such a query. If you do not
use the interactive parameter, the system uses a default type instead. You can issue this statement
from the MapBasic window in MapInfo Pro.
Syntax
[ CoordSys... ]
[ Version version_pro ] ]
[ Interactive ]
[ BlockSize block_size ]
[ { Interactive | Automatic commit_keyword } ]
[ ConvertObjects { ON | OFF | INTERACTIVE } ]
tablename is the name of the table as you want it to appear in database. The name can include a
schema name, which specifies the schema that the table belongs to. If no schema name is provided,
the table belongs to the default schema. The user is responsible for providing an eligible schema
name and must know if the login user has the proper permissions on the given schema. This
extension is for SQL Server 2005 only. When used with the GPKG clause, it is the name of the table
as you want it to appear in GeoPackage.
filespec is a file specification (optionally including directory path). This is where the MapInfo .TAB
file is saved.
char_set is the name of a character set; see CharSet clause.
locale is a string that specifies the locale of the index to create, such as "en-US". If not set, then the
default system locale is used.
version is an expression that specifies the version of the Microsoft Jet database format to be used
by the new database. Acceptable values are 4.0 (for Access 2000), 3.0 (for Access '95/'97), 12.0
(for Access 2007). If omitted, the default version is 12.0. If the database in which the table is being
created already exists, the specified database version is ignored.
database_filespec a string that identifies the name and path of a valid:
• Access database when used with Access. If the specified database does not exist, MapInfo Pro
creates a new Access (.MDB or .ACCDB) file.
Description
If no As clause is specified, the Commit Table statement saves any pending edits to the table. This
is analogous to the user choosing the Save command in MapInfo Pro.
A Commit Table statement that includes an As clause has the same effect as a user choosing the
Save Copy As command. The As clause can be used to save the table with a different name,
directory, file type, or projection.
To save the table under a new name, specify the new name in the filespec string. To save the table
in a new directory path, specify the directory path at the start of the filespec string.
The optional Type clause indicates the format of the local cache table, as either MapInfo (NATIVE)
or MapInfo Extended (NATIVEX). Use a Type clause within the As clause. The NATIVEX format
supports table caches larger than 2GB in size and character sets UTF-8 and UTF-16. When the
The Type clause is not specified, then the table type defaults to NATIVE.
The optional Charset clause is set with the Type clause and saves to a specific character set. The
char_set parameter should be a string constant, such as "WindowsLatin1". See CharSet clause
for more information.
• If not provided with the Type clause, the character set of the source table is assumed. Using an
incompatible character set may cause the character data in the destination table to convert into
underscores (such as WindowsCyrillic to WindowsLatin1). The preference is to convert to or from
UTF-8 or UTF-16 character sets.
• If not provided with the DBF and Table clauses, MapBasic uses the default character set for the
hardware platform that is in use at runtime. Note, the Commit Table statement does not support
UTF-8 or UTF-16 for DBF.
The Locale clause is set with the NATIVEX clause to specify the locale of the index to create, which
will affect the sorting behavior of the table. It takes a string value, such as "en-US". If not specified,
default system locale is used. This clause only applies to NativeX tables with a character set (charset)
of UTF-8 or UTF-16.
To save the table using a different coordinate system or projection, include a CoordSys clause
within the As clause. Note that only a mappable table may have a coordinate system or a projection.
To save a Query use the QUERY type for the table. Only queries made from the user interface and
queries created from Run Command statements in MapBasic can be saved. The Commit Table
statement creates a .TAB file and a .QRY file.
The Version clause controls the table's format. If you specify Version 100, MapInfo Pro stores the
table in a format readable by versions of MapInfo Pro. If you specify Version 300, MapInfo Pro stores
the table in MapInfo Pro 3.0 format. Note that region and polyline objects having more than 8,000
nodes and multiple-segment polyline objects require version 300. If you omit the Version clause,
the table is saved in the version 300 format.
Note: If a MapBasic application issues a Commit Table...As statement affecting a table which
has memo fields, the memo fields will not be retained in the new table. No warning will be
displayed. If the table is saved to a new table through MapInfo Pro's user interface (by
choosing Save Copy As), MapInfo Pro warns the user about the loss of the memo fields.
However, when the table is saved to a new table name through a MapBasic program, no
warning appears.
The ODBC clause indicates a copy of the Table will be saved on the DBMS specified by
ConnectionNumber.
Setting the SQLServerSpatial clause supports spatial data with GEOGRAPHY and GEOMETRY
data types.
The ConvertDateTime If the source table contains Time or Date type columns, these columns will
be converted to DATETIME or TIMESTAMP depending on whether the server supports the data
types. However, you can control this behavior using the clause ConvertDateTime. If the source table
does not contain a Time or Date type, this clause is a non-operational. If ConvertDateTime is set
to ON (which is the default setting), Time or Date type columns will be converted to DATETIME or
TIMESTAMP. If ConvertDateTime is set to OFF, the conversion is not done and the operation will
be canceled if necessary. If ConvertDateTime is set to INTERACTIVE a dialog box will pop up to
prompt the user and the operation will depend on the user's choice. If the user chooses to convert,
then the operation will convert and continue; if the user chooses to cancel, the operation will be
canceled.
The Time type requires conversion for all supported servers (Oracle, PostGIS, SQL Server Spatial,
MS SQL Server and Access) and the Date type requires conversion for MS SQL Server and Access
database servers.
Note: For MS SQL Server and Access database servers, this restriction could be a backward
compatibility issue. We suggest you use the DATETIME data type instead of TIMESTAMP
data type. If you still use the DATETIME data type, the conversion operation will fail.
ConvertDateTime Examples
Issue the following query in the SQL Select dialog box and click OK or type this query in the
MapBasic window:
When you select select the current query and then click the Save Copy As button, the following
error message displays:
Typically this dialog box contains a list of all columns that contain indeterminate types. In this query,
there is only one.
Click OK to display the Set Field Properties dialog box.
Use this dialog box to select the type information for this column. If there is more than one
indeterminate type, you can set each of these types one at a time. If there are columns whose type
is already defined, you will not be able to edit that information.
Click OK to save your query.
Automatic NoCollision
In the event of a conflict, MapInfo Pro does not perform the save. (This is the default behavior if the
statement does not include an Interactive clause or an Automatic clause.)
Automatic ApplyUpdates
In the event of a conflict, MapInfo Pro saves the local updates. (This is analogous to ignoring conflicts
entirely.)
Automatic DiscardUpdates
In the event of a conflict, MapInfo Pro saves the local updates already in the RDBMS (discards your
local updates). You can copy a linked table by using the As clause; however, the new copy is not
a linked table and no changes are updated to the server.
ODBC Connection
The length of tablename varies with databases. We recommend 14 or fewer characters for a table
name in order to work correctly for all databases. The statement limits the length of the tablename
to a maximum of 31 characters.
If the As clause is used and ODBC is the Type, a copy of the table will be saved on the database
specified by ConnectionNumber and named as tablename. If the source table is mappable, three
more columns, Key column, Object column, and Style column, may be added to the destination
database table, tablename, whether or not the source table has those columns. If the source table
is not mappable, one more column, Key column, may be added to the database table, tablename,
even if the source table does not have a Key column. The Key column will be used to create a
unique index.
A spatial index will be created on the Object column if one is present. The supported databases
include Oracle, SQL Server, IIS (SQL Server Spatial, Universal Server), and Microsoft Access.
However, to save a table with a spatial geometry/object, (including saving a point-only table)
SpatialWare is required for SQL Server, in addition to the spatial option for Oracle. The XY schema
is not supported in this statement.
Example
The following example opens the table STATES, then uses the Commit Table statement to make
a copy of the states table under a new name (ALBERS). The optional CoordSys clause causes
the ALBERS table to be saved using the Albers equal-area projection.
See Also:
Rollback statement
ConnectObjects() function
Purpose
Returns an object representing the shortest or longest distance between two objects. You can call
this function from the MapBasic window in MapInfo Pro.
Syntax
Return Value
This statement returns a single section, two-point Polyline object representing either the closest
distance (min == TRUE) or farthest distance (min == FALSE) between object1 and object2.
Description
One point of the resulting Polyline object is on object1 and the other point is on object2. Note that
the distance between the two input objects can be calculated using the ObjectLen() function. If
there are multiple instances where the minimum or maximum distance exists (e.g., the two points
returned are not uniquely the shortest distance and there are other points representing "ties") then
these functions return one of the instances. There is no way to determine if the object returned is
uniquely the shortest distance.
ConnectObjects() returns a Polyline object connecting object1 and object2 in the shortest (min ==
TRUE) or longest (min == FALSE) way using a spherical calculation method. If the calculation cannot
be done using a spherical distance method (e.g., if the MapBasic coordinate system is NonEarth),
then a Cartesian method will be used.
Continue statement
Purpose
Resumes the execution of a MapBasic program (following a Stop statement). You can issue this
statement from the MapBasic window in MapInfo Pro.
Syntax
Continue
Restrictions
The Continue statement may only be issued from the MapBasic window; it may not be included
as part of a compiled program.
Description
The Continue statement resumes the execution of a MapBasic application which was suspended
because of a Stop statement.
You can include Stop statements in a program for debugging purposes. When a MapBasic program
encounters a Stop statement, the program is suspended, and the File menu automatically changes
to include a Continue Program option instead of a Run option. You can resume the suspended
application by choosing File > Continue Program. Typing the Continue statement into the MapBasic
window has the same effect as choosing Continue Program.
Syntax
control_ID is an integer; cannot be the same as the ID of another control in the dialog box.
handler is the name of a procedure to call if the user clicks on the button.
title_string is a text string to appear on the button.
Description
If a Dialog statement includes a Control Button clause, the dialog box includes a push-button
control. If the OKButton keyword appears in place of the Button keyword, the control is a special
type of button; the user chooses an OKButton control to "choose OK" and dismiss the dialog box.
Similarly, the user chooses a CancelButton control to "choose Cancel" and dismiss the dialog box.
Each dialog box should have no more than one OKButton control, and have no more than one
CancelButton control. Disable makes the control disabled (grayed out) initially. Hide makes the
control hidden initially.
Use the Alter Control statement to change a control's status (e.g., whether the control is enabled
or hidden).
Example
Control Button
Title "&Reset"
Calling reset_sub
Position 10, 190
See Also:
Alter Control statement, Dialog statement
Syntax
Control CheckBox
[ Position x, y ] [ Width w ]
[ ID control_ID ]
[ Calling handler ]
[ Title title_string ]
[ Value log_value ]
[ Into log_variable ]
[ Disable ] [ Hide ]
control_ID is an integer; cannot be the same as the ID of another control in the dialog box.
handler is the name of a procedure to call if the user clicks on the control.
title_string is a text string to appear in the label to the right of the check-box.
log_value is a logical value: FALSE sets the control to appear un-checked initially.
log_variable is the name of a logical variable.
Description
If a Dialog statement includes a Control CheckBox clause, the dialog box includes a check box
control.
The Value clause controls the initial appearance. If the Value clause is omitted, or if it specifies a
value of TRUE, the check box is checked initially. If the Value clause specifies a FALSE value,
check-box is clear initially. Disable makes the control disabled (grayed out) initially. Hide makes
the control hidden initially.
Example
Control CheckBox
Title "Include &Legend"
Into showlegend
ID 6
Position 115, 155
See Also:
Alter Control statement, Dialog statement, ReadControlValue() function
Syntax
Control DocumentWindow
[ Position x, y ]
[ Width w ] [ Height h ]
[ ID control_ID ]
[ Disable ] [ Hide ]
h specifies the height of the control in dialog units; default height is 100.
control_ID is an integer; cannot be the same as the ID of another control in the dialog box.
Disable grays out the control initially.
Hide initially hides the control.
Description
If a Dialog statement includes a Control DocumentWindow clause, the dialog box includes a
document window control that can be re-parented using the Set Next Document statement.
Example
The following example draws a legend in a dialog box:
Control DocumentWindow
ID ID_LEGENDWINDOW
Position 160, 20
Width 120 Height 150
The dialog box handler will need to re-parent the window as in the following example:
Sub DialogHandler
OnError Goto HandleError
Dim iHwnd As Integer
Alter Control ID_LEGENDWINDOW Enable Show
' draw the legend
iHwnd = ReadControlValue(ID_LEGENDWINDOW)
Set Next Document Parent iHwnd Style WIN_STYLE_CHILD
Create Legend
Exit Sub
HandleError:
Note "DialogHandler: " + Error$()
End Sub
See Also:
Dialog statement
Syntax
Control EditText
[ Position x, y ] [ Width w ] [ Height h ]
[ ID control_ID ]
[ Value initial_value ]
[ Into variable ]
[ Disable ] [ Hide ] [ Password ]
Description
If the user types more text than can fit in the box at one time, MapInfo Pro automatically scrolls the
text to make room. An EditText control can hold up to 32,767 characters.
If the height is large enough to fit two or more lines of text (for example, if the height is larger than
20), MapInfo Pro automatically wraps text down to successive lines as the user types. If the user
enters a line-feed into the EditText box (for example, on Windows, if the user presses Ctrl+Enter
while in the EditText box), the string associated with the EditText control will contain a Chr$(10)
value at the location of each line-feed. If the initial_value expression contains embedded Chr$(10)
values, the text appears formatted when the dialog box appears.
To make an EditText control the active control, use an Alter Control...Active statement.
Example
Control EditText
Value "Franchise Locations"
Position 65, 8 Width 90
ID 1
Into s_map_title
See Also:
Alter Control statement, Dialog statement, ReadControlValue() function
Syntax
Control GroupBox
[ Position x, y ] [ Width w ] [ Height h ]
[ ID control_ID ]
[ Title title_string ]
[ Hide ]
Example
Control GroupBox
Title "Level of Detail"
Position 5, 30
Height 40 Width 70
See Also:
Alter Control statement, Dialog statement
Syntax
Description
If a Dialog statement includes a Control ListBox clause, the dialog box includes a listbox control.
If the list contains more items than can be shown in the control at one time, MapBasic automatically
adds a scroll-bar at the right side of the control.
A MultiListBox control is identical to a ListBox control, except that the user can Shift+Click to select
multiple items from a MultiListBox control.
The Title clause specifies the contents of the list. If the Title clause specifies a string expression
containing a semicolon-delimited list of items, each item appears as one item in the list. The following
sample Title clause demonstrates this syntax:
Alternately, if the Title clause specifies an array of string variables, each entry in the array appears
as one item in the list. The following sample Title clause demonstrates this syntax:
control). Within the handler procedure, set up a loop to call the ReadControlValue() function
repeatedly.
The first call to the ReadControlValue() function returns the number of the first selected item; the
second call to the ReadControlValue() function returns the number of the second selected item;
etc. When the ReadControlValue() function returns zero, you have exhausted the list of selected
items. If the first call to the ReadControlValue() function returns zero, there are no list items
selected.
Sub lb_handler
Dim i As SmallInt
If CommandInfo(CMD_INFO_DLG_DBL) Then
' ... then the user double-clicked.
i = ReadControlValue( TriggerControl() )
Dialog Remove
' at this point, the variable i represents
' the selected list item...
End If
End Sub
Example
Control ListBox
Title "1st Quarter;2nd Quarter;3rd Quarter;4th Quarter"
ID 3
Value 1
Into i_quarter
Position 10, 92 Height 40
The NVIEWS.MB sample program demonstrates how to create a dialog box which provides special
handling for when the user double-clicks. The NVIEWS program displays a dialog box with a ListBox
control. To complete the dialog box, the user can click on a list item and then choose OK, or the
user can double-click an item in the list.
The following Control ListBox clause adds a list to the Named Views dialog box. Note that the
ListBox control has a handler routine, "listbox_handler."
Control ListBox
Title desc_list
ID 1
Position 10, 20 Width 245 Height 64
Calling listbox_handler
If the user clicks or double-clicks on the ListBox control, MapBasic calls the sub procedure
"listbox_handler." The procedure calls the CommandInfo() function to determine whether the user
clicked or double-clicked. If the user double-clicked, the procedure issues a Dialog Remove
statement to dismiss the dialog box. If not for the Dialog Remove statement, the dialog box would
remain on the screen until the user clicked OK or Cancel.
Sub listbox_handler
Dim i As SmallInt
' First, since user clicked on the name of a view,
' we can enable the OK button and the Delete button.
Alter Control 2 Enable
Alter Control 3 Enable
If CommandInfo(CMD_INFO_DLG_DBL) = TRUE Then
' ...then the user DOUBLE-clicked.
' see which list item the user clicked on.
i = ReadControlValue(1) ' read user's choice.
Dialog Remove
Call go_to_view(i) ' act on user's choice.
End If
End Sub
MapBasic calls the handler procedure whether the user clicks or double-clicks. The handler procedure
must check to determine whether the event was a single- or double-click.
See Also:
Alter Control statement, Dialog statement, ReadControlValue() function, CommandInfo()
function
Syntax
[ ID control_ID ]
[ Calling handler ]
[ Value style_expr ]
[ Into style_var ]
[ Disable ] [ Hide ]
Description
A Picker control (PenPicker, BrushPicker, SymbolPicker, or FontPicker) is a button showing a pen,
brush, symbol, or font style. If the user clicks on the button, a dialog box appears to allow the user
to change the style.
Example
Control SymbolPicker
Position 140,42
Into sym_storemarker
See Also:
Alter Control statement, Dialog statement, ReadControlValue() function
ControlPointInfo() function
Purpose:
Returns raster and geographic control point coordinates for an image table. The geographic
coordinates will be in the current MapBasic coordinate system.
Syntax:
table_id is a string representing a table name, a positive integer table number, or 0 (zero). The table
must be a raster, grid or WMS table.
attribute is an integer code indicating which aspect of the control point to return.
controlpoint_num is the integer number of which control point to return. Control point numbers start
at 1. The maximum control point number can be found by calling
RasterTableInfo(table_id, RASTER_TAB_INFO_NUM_CONTROL_POINTS)
Return Value
The X or Y raster coordinate is returned as an Integer. The X or Y geographic coordinate is returned
as a Float. The return type depends upon the attribute flag, for the control point specified by
controlpoint_num.
The attribute parameter can be any value from the table below. Codes in the left column (for example,
RASTER_CONTROL_POINT_X) are defined in MAPBASIC.DEF.
Syntax
Control PopupMenu
[ Position x, y ]
[ Width w ]
[ ID control_ID ]
[ Calling handler ]
[ Title { str_expr | From Variable str_array_var } ]
[ Value i_selected ]
[ Into i_variable ]
[ Disable ]
Description
If a Dialog statement includes a Control PopupMenu clause, the dialog box includes a pop-up
menu. A pop-up menu is a list of items, one of which is selected at one time. Initially, only the selected
item appears on the dialog box.
If the user clicks on the control, the entire menu appears, and the user can choose a different item
from the menu.
The Title clause specifies the list of items that appear in the menu. If the Title clause specifies a
string expression containing a semicolon-delimited list of items, each item appears as one item in
the menu. The following sample Title clause demonstrates this syntax:
Alternately, the Title clause can specify an array of string variables, in which case each entry in the
array appears as one item in the popup menu.
The following sample Title clause demonstrates this syntax:
Example
Control PopupMenu
Title "Town;County;Territory;Region;Entire state"
Value 2
ID 5
Into i_map_scope
Position 10, 150
See Also:
Alter Control statement, Dialog statement, ReadControlValue() function
Syntax
Control RadioGroup
[ Position x, y ]
[ ID control_ID ]
[ Calling handler ]
[ Title { str_expr | From Variable str_array_var } ]
[ Value i_selected ]
[ Into i_variable ]
[ Disable ] [ Hide ]
str_expr is a string expression, containing a semicolon-delimited list of items to appear in the control.
str_array_var is the name of an array of string variables.
i_selected is a SmallInt value indicating which item should appear selected when the dialog box
first appears: a value of one selects the first item; if the clause is omitted, the first item appears
selected.
i_variable is the name of a SmallInt variable which stores the user's final selection (one, if the first
item selected, etc.).
The Disable keyword makes the control disabled (grayed out) initially.
The Hide keyword makes the control hidden initially.
Description
If a Dialog statement includes a Control RadioGroup clause, the dialog box includes a group of
radio buttons. Each radio button is a label to the right of a hollow or filled circle. The currently-selected
item is indicated by a filled circle. Only one of the radio buttons may be selected at one time.
The Title clause specifies the list of labels that appear in the dialog box. If the Title clause specifies
a string expression containing a semicolon-delimited list of items, each item appears as one item
in the list.
The following sample Title clause demonstrates this syntax:
Alternately, the Title clause can specify an array of string variables, in which case each entry in the
array appears as one item in the list. The following sample Title clause demonstrates this syntax:
Example
Control RadioGroup
Title "&Full Details;&Partial Details"
Value 2
ID 2
Into i_details
Calling rg_handler
Position 15, 42
See Also:
Alter Control statement, Dialog statement, ReadControlValue() function
Syntax
Control StaticText
[ Position x, y ]
[ Width w ] [ Height h ]
[ ID control_ID ]
[ Title title_string ]
[ Hide ]
Description
If you want the text string to wrap down onto multiple lines, include the optional Width and Height
clauses. If you omit the Width and Height clauses, the static text control shows only one line of
text.
Example
Control StaticText
Title "Enter map title:"
Position 5, 10
See Also:
Alter Control statement, Dialog statement
ConvertToPline() function
Purpose
Returns a polyline object that approximates the shape of another object. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
ConvertToPline( object )
object is the object to convert; may not be a point object or a text object.
Return Value
A polyline object
Description
The ConvertToPline() function returns a polyline object which approximates the object parameter.
Thus, if the object parameter represents a region object, ConvertToPline() returns a polyline that
has the same shape and same number of nodes as the region.
The results obtained by calling ConvertToPline() are similar to the results obtained by choosing
MapInfo Pro's Convert To Polylines command. However, the function ConvertToPline() does not
alter the original object.
See Also:
Objects Enclose statement
ConvertToRegion() function
Purpose
Returns a region object that approximates the shape of another object. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
ConvertToRegion( object )
object is the object to convert; may not be a point, line, or text object.
Return Value
A region object
Description
Retains most style attributes. Other attributes are determined by the current pens or brushes. A
polyline whose first and last nodes are identical will not have the last node duplicated. Otherwise,
MapInfo Pro adds a last node whose vertices are the same as the first node.
The ConvertToRegion() function returns a region object which approximates the object parameter.
Thus, if the object parameter represents a rectangle, ConvertToRegion() returns a region that looks
like a rectangle.
The results obtained by calling ConvertToRegion() are similar to the results obtained by choosing
MapInfo Pro's Convert To Regions command on the SPATIAL tab. However, the
ConvertToRegion() function does not alter the original object.
See Also:
Objects Enclose statement
ConvexHull() function
Purpose
Returns a region object that represents the convex hull polygon based on the nodes from the input
object. The convex hull polygon can be thought of as an operator that places a rubber band around
all of the points. It will consist of the minimal set of points such that all other points lie on or inside
the polygon. The polygon will be convex―no interior angle can be greater than 180 degrees. You
can call this function from the MapBasic window in MapInfo Pro.
Syntax
ConvexHull( inputobject )
Return Value
Returns a region object.
Description
The ConvexHull() function returns a region representing the convex hull of the set of points
comprising the input object. The ConvexHull() function operates on one single object at a time. To
create a convex hull around a set of objects, use the Create Object As ConvexHull statement.
Example
The following program selects New York from the States file, then creates a ConvexHull surrounding
the selection.
See Also:
Create Object statement
CoordSys clause
Purpose
Specifies a coordinate system. You can use this clause in the MapBasic window in MapInfo Pro
(see CoordSys Earth and NonEarth Projection, CoordSys Layout Units, CoordSys Table, and
CoordSys Window).
CoordSys Earth
[ Projection type, datum, unitname
[ , origin_longitude ] [ , origin_latitude ]
[ , standard_parallel_1 [ , standard_parallel_2 ] ]
[ , azimuth ] [ , scale_factor ]
[ , false_easting ] [ , false_northing ]
[ , range ] ]
[ Affine Units unitname, A, B, C, D, E, F ]
[ Bounds ( minx, miny ) ( maxx, maxy ) ]
CoordSys Nonearth
[ Affine Units unitname, A, B, C, D, E, F ]
Units unitname
[ Bounds ( minx, miny ) ( maxx, maxy ) ]
Description
The CoordSys clause specifies a coordinate system, and, optionally, specifies a map projection to
use in conjunction with the coordinate system. Note that CoordSys is a clause, not a complete
MapBasic statement. Various statements may include the CoordSys clause; for example, a Set
Map statement can include a CoordSys clause, in which case the Set Map statement will reset
the map projection used by the corresponding Map window.
Use CoordSys Earth (syntax 1) to explicitly define a coordinate system for an Earth map (a map
having coordinates which are specified with respect to a location on the surface of the Earth). The
optional Projection parameters dictate what map projection, if any, should be used in conjunction
with the coordinate system. If the Projection clause is omitted, MapBasic uses datum 0. The Affine
clause describes the affine transformation for producing the derived coordinate system. If the
Projection clause is omitted, the base coordinate system is Longitude/Latitude. Since the derived
coordinates may be in different units than the base coordinates, the Affine clause requires you to
specify the derived coordinate units.
Use CoordSys Nonearth (syntax 2) to explicitly define a non-Earth coordinate system, such as the
coordinate system used in a floor plan or other CAD drawing. In the CoordSys Non-Earth case,
the base coordinate system is an arbitrary Cartesian grid. The Units clause specifies the base
coordinate units, and the Affine clause specifies the derived coordinate units.
When a CoordSys clause appears as part of a Set Map statement or Set Digitizer statement,
the Bounds subclause is ignored. The Bounds subclause is required for non-Earth maps when
the CoordSys clause appears in any other statement, but only for non-Earth maps.
The Bounds clause defines the map's limits; objects may not be created outside of those limits.
When specifying an Earth coordinate system, you may omit the Bounds clause, in which case
MapInfo Pro uses default bounds that encompass the entire Earth.
Note: In a Create Map statement, you can increase the precision of the coordinates in the map
by specifying narrower Bounds.
Every map projection is defined as an equation; and since the different projection equations have
different sets of parameters, different CoordSys clauses may have varying numbers of parameters
in the optional Projection clause. For example, the formula for a Robinson projection uses the
datum, unitname, and origin_latitude parameters, while the formula for a Transverse Mercator
projection uses the datum, unitname, origin_longitude, origin_latitude, scale_factor, false_easting,
and false_northing parameters.
For more information on projections and coordinate systems, see the MapInfo Pro documentation.
Each MapBasic application has its own CoordSys setting that specifies the coordinate system used
by the application. If a MapBasic application issues a Set CoordSys statement, other MapBasic
applications which are also in use will not be affected.
Examples
The Set Map statement controls the settings of an existing Map window. The Set Map statement
below tells MapInfo Pro to display the Map window using the Robinson projection:
The first 12 specifies the Robinson projection; the second 12 specifies the Sphere datum; the "m"
specifies that the coordinate system should use meters; and the final zero specifies that the origin
of the map should be at zero degrees longitude.
The following statement tells MapInfo Pro to display the Map window without any projection.
The following example opens the table World, then uses a Commit Table statement to save a copy
of World under the name RWorld. The new RWorld table will be saved with the Robinson projection.
The following example defines a coordinate system called DCS that is derived from UTM Zone 10
coordinate system using the affine transformation.
In this transformation, (x1, y1) represents the DCS derived coordinates, and (x, y) represents the
UTM Zone 10 base coordinates. If the DCS coordinates are measured in feet, the CoordSys clause
for DCS would be as follows:
CoordSys Earth
Projection 8, 74, "m", -123, 0, 0.9996, 500000, 0
Affine Units "ft", 1.57, -0.21, 84120.5, 0.19, 2.81, -20318.0
Syntax
paperunitname is a string representing a paper unit of measure (for example, "in" for inches); for a
list of unit names, see Set Paper Units statement.
Description
Use CoordSys Layout to define a coordinate system which represents a MapInfo Pro Layout
window. A MapBasic program must issue a Set CoordSys Layout statement before querying,
creating or otherwise manipulating Layout objects. The unitname parameter is the name of a paper
unit, such as "in" for inches or "cm" for centimeters.
Examples
The following Set CoordSys statement assigns a Layout window's coordinate system, using inches
as the unit of measure:
CoordSys Table
Syntax
Description
Use CoordSys Table to refer to the coordinate system in which a table has been saved.
CoordSys Window
Syntax
Description
Use CoordSys Window to refer to the coordinate system already in use in a window.
Examples
The following example sets one Map window's projection to match the projection of another Map
window. This example assumes that two integer variables (first_map_id and second_map_id) already
contain the window IDs of the two Map windows.
Set Map
Window second_map_winid
CoordSys Window first_map_winid
See Also:
Commit Table statement, Set CoordSys statement, Set Map statement
CoordSysName$() function
Purpose
Returns coordinate system name string from MapBasic Coordinate system clause. You can call this
function from the MapBasic window in MapInfo Pro.
Syntax
CoordSysName$ ( string )
Return Value
String
Example
Note: If a coordinate system name does not exist in the MapInfow.prj file, such as when the map
is in NonEarth system in Survey Feet, then function will return an empty string.
Then an Error regarding the Invalid Coordinate System should be returned (Error #727).
CoordSysStringToEPSG() function
Purpose
Converts a MapBasic Coordinate System clause into an EPSG integer value for use with any
MapBasic function or statement. You can call this function from the MapBasic window in MapInfo
Pro.
Syntax
CoordSysStringToEPSG ( coordsys_string )
coordsys_string is a MapBasic CoordSys clause. EPSG (European Petroleum Survey Group) value
is an integer value; for example, CoordSys Clause of "Earth Projection 1, 104" will return an EPSG
code of 4326. For a complete list of EPSG codes used with MapInfo Pro see the MAPINFOW.PRJ
file in your MapInfo Pro installation. The EPSG codes are identified by a "\p" followed by a number.
Return Value
Integer. If no EPSG value is found, it returns -1.
Description
The CoordSysStringToEPSG() function is used to convert a MapBasic CoordSys clause into an
integer EPSG value.
Example
The following example displays EPSG code Earth Projection 1, 104 Coordinate System.
See Also:
CoordSys clause
CoordSysStringToPRJ$() function
Purpose
Converts MapBasic Coordinate System clause into an PRJ string. PRJ string format is used to
describe MapInfo Coordinate Systems in mapinfow.prj file. You can call this function from the
MapBasic window in MapInfo Pro.
Syntax
CoordSysStringToPRJ$( coordsys_string )
Return Value
string
Description
The CoordSysStringToPRJ$() function is used to convert a MapBasic CoordSys clause into an
integer EPSG value.
Example
The following example displays PRJ string for Earth Projection 1, 104 Coordinate System.
See Also:
CoordSys clause
CoordSysStringToWKT$() function
Purpose
Converts a CoordSys clause into an WKT (Well-Known Text) string value. You can call this function
from the MapBasic window in MapInfo Pro.
Syntax
CoordSysStringToWKT$( coordsys_string )
Return Value
WKT string. If no WKT string value is found, returns an empty string.
Example
The following example:
PROJCS["_MI_0",GEOGCS[
,DATUM["North_American_Datum_1983",SPHEROID["Geodet
ic Reference System of
1980",6378137,298.2572221009113],AUTHORITY["EPSG","6269"]],PRIMEM["Greenw
ich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercato
r"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-
123],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],P
ARAMETER["false_northing",0],UNIT["METER",1]]
See Also:
CoordSys clause
Cos() function
Purpose
Returns the cosine of a number. You can call this function from the MapBasic window in MapInfo
Pro.
Syntax
Cos( num_expr )
Return Value
Float
Description
The Cos() function returns the cosine of the numeric num_expr value, which represents an angle
in radians. The result returned from Cos() is between one (1) and negative one (-1).
To convert a degree value to radians, multiply that value by DEG_2_RAD. To convert a radian value
into degrees, multiply that value by RAD_2_DEG.
Note: Your program must Include "MAPBASIC.DEF" to reference DEG_2_RAD or RAD_2_DEG.
Example
Include "MAPBASIC.DEF"
Dim x, y As Float
x = 60 * DEG_2_RAD
y = Cos(x)
See Also:
Acos() function, Asin() function, Atn() function, Sin() function, Tan() function
Syntax
Create Adornment
From Window map_window_id
Type adornment_type
[ Position {
[ Fixed [ ( x, y ) [ Units paper_units ] ] ] |
[ win_position [ Offset (x, y) ] [Units paper_units ] ]
} ]
[ Layout Fixed Position { Frame | Geographic } ]
[ Size [ Width win_width ] [ Height win_height ] [ Units paper_units
] ]
[ Background [ Brush ... ] [ Pen ... ] ]
[ < SCALEBAR CLAUSE > ]
[ BarType type ]
[ Ground Units distance_units ]
[ Display Units paper_units ]
[ BarLength paper_length ]
[ BarHeight paper_height ]
[ BarStyle [ Pen .... ] [ Brush ... ] [ Font ... ] ]
[ Scale [ { On | Off } ] ]
[ Auto [ { On | Off } ] ]
ADORNMENT_INFO_MAP_POS_TL (0)
ADORNMENT_INFO_MAP_POS_TC (1)
ADORNMENT_INFO_MAP_POS_TR (2)
ADORNMENT_INFO_MAP_POS_CL (3)
ADORNMENT_INFO_MAP_POS_CC (4)
ADORNMENT_INFO_MAP_POS_CR (5)
ADORNMENT_INFO_MAP_POS_BL (6)
ADORNMENT_INFO_MAP_POS_BC (7)
ADORNMENT_INFO_MAP_POS_BR (8)
(x, y) in the Offset clause is measured from the anchor position. For example, if the win_position
is ADORNMENT_INFO_MAP_POS_TL (top left), then the x is to the right and the y is down. If the
win_position is ADORNMENT_INFO_MAP_POS_BR, then the x position is left and the y position
is up. In the center left (ADORNMENT_INFO_MAP_POS_CL) and center right
(ADORNMENT_INFO_MAP_POS_CR), the y offset is ignored. In the center position
(ADORNMENT_INFO_MAP_POS_CC), the offset is ignored completely (both x and y). In the top
center (ADORNMENT_INFO_MAP_POS_TC) and bottom center
(ADORNMENT_INFO_MAP_POS_BC) positions, the x offset is ignored. For
ADORNMENT_INFO_MAP_POS_ defines, see win_position.
win_width and win_height define the size of the adornment. MapInfo Pro ignores these parameters
if this is a scale bar adornment, because scale bar adornment size is determined by scale bar specific
items, such as BarLength.
type specify one of the following codes; codes are defined in the MAPBASIC.DEF file.
SCALEBAR_INFO_BARTYPE_CHECKEDBAR (0)
SCALEBAR_INFO_BARTYPE_SOLIDBAR (1)
SCALEBAR_INFO_BARTYPE_LINEBAR (2)
SCALEBAR_INFO_BARTYPE_TICKBAR (3)
"ch" chains
"cm" centimeters
"ft" feet (also called International Feet; one International Foot equals exactly 30.48 cm)
"in" inches
"km" kilometers
"li" links
"m" meters
"mi" miles
"mm" millimeters
"rd" rods
"survey ft" U.S. survey feet (used for 1927 State Plane coordinates; one U.S. Survey Foot equals exactly
12/39.37 meters, or approximately 30.48006 cm)
"yd" yards
paper_length a value in paper_units to specify how long the scale bar will be displayed. Specify the
length of the scale bar to a maximum of 34 inches or 86.3 cm on the printed map.
paper_height a value in paper_units to specify how tall the scale bar will be displayed. Specify height
of the adornment to a maximum of 44 inches or 111.76cm on the printed map.
paper_units is a string representing a paper unit name: cm (centimeters), mm (millimeters), in
(inches), pt (points), and pica.
• 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
• 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
• 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
• 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
• 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points
Description
The scale bar displays as a paper_length bar in the paper_units.
Position can be Fixed relative to the mapper upper left regardless of the size of the mapper, or
relative to some anchor point on the mapper specified by win_position.
Offset is the amount the adornment will be offset from the mapper when using one of the docked
win_position.
Layout Fixed Position determines how an adornment is positioned in a layout when the adornment
is using Fixed positioning. If this is set to Geographic, then the adornment is placed on the same
geographic place on the map frame in the layout as it is in the mapper. If the layout frame changes
size, then the adornment will move relative to the frame to match the geographic position. If this is
set to Frame, then the adornment will remain at a fixed position relative to the frame, as designated
in the Position clause. If the Position clause positions the adornment at (1.0, 1.0) inches, then the
adornment will be placed 1 inch to the left and one inch down from the upper left corner of the frame.
Changing the size of the frame will not change the position of the adornment. The default is
Geographic.
Offset is the amount the adornment will be offset from the mapper when using one of the docked
win_positions.
The Background clause when used with Brush denotes the fill pattern to be used in the background
while creating or modifying a scale bar. When used with the Pen clause, this denotes the border to
be used in the background while creating or modifying a scale bar.
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 adornment.
Pen is a valid Pen clause. Due to window clipping (the adornment is a window within the mapper),
Pen widths other than 1 may not display correctly. Also, Pen styles other than solid may not display
correctly. This clause is designed to turn on (solid) or off (hollow) and set the color of the border of
the adornment.
Font is a valid Font clause.
The Auto clause set to On shows values that have been automatically rounded in the scale bar. If
the clause is set to Off, the values will not be rounded and will be shown like they had been in earlier
versions. The default is Auto Off, if not already specified.
Use Scale set to On to include a representative fraction (RF) with the scale bar. (In MapInfo Pro, a
map scale that does not include distance units, such as 1:63,360 or 1:1,000,000, is called a
cartographic scale.)
Example
If the paper_length is 1 and the paper_unit is inches, then the scale bar displays as 1 inch. It is
labeled in the distance_unit for the current amount that paper_unit spans, and it dynamically updates
as the map changes (e.g., zoom and pan). The default distance_unit is the current distance unit in
the mapper. The paper_height determines how tall the scale bar displays. The Pen and Brush
define the style to draw the scale bar with and Font defines the text style for scale bar labeling and
annotation. The Scale parameter displays a cartographic scale.
The following example shows default settings:
create adornment
from window 261763624
type scalebar
position 6 offset (0.000000, 0.000000) units "in"
background Brush (2,16777215,16777215) Pen (1,2,0)
bartype 0 ground units "mi" display units "in"
barlength 1.574803 barheight 0.078740
barstyle Pen (1,2,0) Brush (2,0,16777215) Font ("Arial",0,8,0)
scale on
See Also:
Set Adornment statement
Syntax
Create Arc
[ Into { Window window_id | Variable var_name } ]
( x1, y1 ) ( x2, y2 )
start_angle end_angle
[ Pen... ]
x1, y1 specifies one corner of the minimum bounding rectangle (MBR) of an ellipse; the arc produced
will be a section of this ellipse.
x2, y2 specifies the opposite corner of the ellipse's MBR.
start_angle specifies the arc's starting angle, in degrees.
end_angle specifies the arc's ending angle, in degrees.
The Pen clause specifies a line style.
Description
The Create Arc statement creates an arc object.
If the statement includes the optional Into Variable clause, the object will be stored in the specified
object variable. If the Into clause specifies a window identifier, the object will be stored in the
appropriate place in the window (for example, in the editable layer of a Map window). If the Into
clause is not provided, MapBasic will attempt to store the object in the topmost window; if objects
may not be stored in the topmost window (for example, if the topmost window is a grapher) no object
will be created.
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. Note that MapBasic's coordinate
system is independent of the coordinate system of any Map window. Objects created on a Layout
window, however, are specified in paper units: each x-coordinate represents a distance from the
left edge of the page, while each y-coordinate represents the distance from the top edge of the
page. For details about paper units, see Set Paper Units statement. By default, MapBasic uses
inches as the default paper unit. To use a different paper unit, use the Set Paper Units statement.
Before creating objects on a Layout window, you must issue a Set CoordSys Layout statement.
The optional Pen clause specifies a line style. If no Pen clause is specified, the Create Arc statement
uses the current MapInfo Pro line style (the style which appears in the Line Style dialog box).
See Also:
Insert statement, Pen clause, Update statement, Set CoordSys statement
Syntax
title_string is the ButtonPad title (for example, "Drawing"). Any whitespaces in the title would be
stripped and any special characters masked.
pad_num is the ID number for the standard toolbar you want to re-define:
• 1 for Main
• 2 for Drawing
• 3 for Tools
• 4 for Standard
• 5 for Database Management System (DBMS)
• 6 Web Services
• 7 Reserved
width is the pad width, in terms of the number of buttons across. Not suppported in the 64-bit version
of MapInfo Pro.
x, y specify the pad's position when it is floating; specified in paper units . For details about paper
units, see Set Paper Units statement. Not suppported in the 64-bit version of MapInfo Pro.
unit_name is a string representing paper units name (for example, "in" for inches, "cm" for
centimeters). Not suppported in the 64-bit version of MapInfo Pro.
row, column specify the pad's position when it is docked as a toolbar (for example, 0, 0 places the
pad at the left edge of the top row of toolbars, and 0, 1 represents the second pad on the top row).
Not suppported in the 64-bit version of MapInfo Pro.
• row position starts at the top and increases in value going to the bottom. It is a relative value to
the rows existing in the same position (top or bottom). When there is a menu bar in the same
position, then the numbers become relative to the menu bar. When a toolbar is just below the
menu bar, its row value is 0. If it is directly above the menu bar, then its row value is -1.
• column position starts at the left and increases in value going to the right. It is a relative value to
the columns existing in the same position (left or right). For example, if a toolbar is docked to the
left and the menu bar is docked to the left position, then the column number for the column left of
the menu bar is -1. The column number for the column to the right of the menu bar is 0.
Each button_definition clause can consist of the keyword Separator, or it can have the following
syntax:
HelpMsg msg specifies the button's status bar help and, optionally, ToolTip help. The first part of
the msg string is the status bar help message. If the msg string includes the letters \n then the text
following the \n is used as the button's ToolTip help.
ModifierKeys clause controls whether the Shift and control (Ctrl) keys affect "rubber-band" drawing
if the user drags the mouse while using a ToolButton. Default is Off, meaning that the Shift and
control (Ctrl) keys have no effect.
Description
Use the Create ButtonPad statement to create a custom ButtonPad. Once you have created a
custom ButtonPad, you can modify it using Alter Button statement and Alter ButtonPad statement.
Each toolbar can be hidden. To create a toolbar in the hidden state, include the Hide keyword.
To set whether the pad is fixed to the top of the screen ("docked") or floating like a window, include
the Fixed or the Float keyword. The user can also control whether the pad is docked or not by
dragging the pad to or from the top of the screen. For more control over the location on the screen
that the pad is docked to, use the Top (which is the same as using Fixed), Left, Right, or Bottom
keywords.
When a toolbar is floating, its position is controlled by the Position clause; when it is docked, its
position is controlled by the ToolbarPosition clause.
For more information on ButtonPads, see the MapBasic User Guide. For additional information
about the capabilities of ToolButtons, see Alter ButtonPad statement.
• The same handler/userId combination; any menu item that calls the same handler/userid from
the same MBX file is assigned that icon).
• The same userId calling different handlers.
• The same handler, no userID.
• ID must be <= 32767.
• For built in handlers, priority is given to find an icon from a built in toolbar. If none is found, then
there is a search through the toolbar icons from the MBX files for a match.
• Small icons are shown next to menu items.
• When an MBX unloads, any of its associated icons are unloaded and are no longer in use for
menu items.
The following describe how MapInfo Pro handles icons for menu items:
• Menu items can show an icon if a MapBasic application creates a toolbar button and menu item
that meet the previously listed requirements for menu item icons.
If you specify a procedure name, the event calls the procedure. The
Calling my_procedure procedure must be part of the same MapBasic program.
Makes a method call to the OLE Automation object set by MapInfo Pro's
Calling OLE "methodname" SetCallback method. See the MapBasic User Guide.
In the last two cases, the string sent to OLE or DDE starts with the three letters "MI:" so that the
server can detect that the message came from MapInfo. The remainder of the string contains a
comma-separated list of the values returned from the function calls CommandInfo(1) through
CommandInfo(8). For complete details on the string syntax, see the MapBasic User Guide.
Examples
Create a button pad of utilities:
Create a toolbar button that launches the Browser Preferences dialog, which has a menu command
ID of 222:
See Also:
Alter Button statement, Alter ButtonPad statement, ButtonPadInfo() function
Syntax
title_string is the ButtonPad title (for example, "Main", "Standard", or "Custom Tools").
pad_num is the ID number for the standard ButtonPad (toolbar) you want to re-define:
• 1 for Main
• 2 for Drawing
• 3 for Tools
• 4 for Standard
• 5 for Database Management System (DBMS)
• 6 Web Services
• 7 Reserved
Custom ButtonPads use only the title_string.
Description
This statement restores MapInfo Pro's standard ButtonPads (such as Main, Drawing, and Tools) to
their default states. Custom ButtonPads will be destroyed.
See Also:
Alter Button statement,Alter ButtonPad statement, Create ButtonPad statement, Create
ButtonPads As Default statement
Syntax
Description
This statement restores MapInfo Pro's standard ButtonPads (such as Main, Drawing, and Tools) to
their default states. Custom ButtonPads will be destroyed.
Use this statement with caution. The Create ButtonPads As Default statement destroys all custom
buttons, even buttons defined by other MapBasic applications.
See Also:
Alter Button statement,Alter ButtonPad statement, Create ButtonPad statement, Create
ButtonPad As Default statement
Syntax
map_window_id is an integer window identifier which you can obtain by calling the FrontWindow()
function and WindowID() function.
x states the desired distance from the top of the workspace to the top edge of the window.
y states the desired distance from the left of the workspace to the left edge of the window.
Note: Here workspace means the client area (which excludes the title bar, tool bar, and the status
bar).
Description
The Create Cartographic Legend statement allows you to create and display cartographic style
legends as well as theme legends for an active map window. Each cartographic and thematic styles
legend will be connected to one, and only one, Map window so that there can be more than one
Legend window open at a time.
You can create a frame for each cartographic or thematic map layer you want to include on the
legend. The cartographic and thematic frames will include a legend title and subtitle. Cartographic
frames display a map layer's styles; legend frames display the colors, symbols, and sizes represented
by the theme. You can create frames that have styles based on the Map window's style or you can
create your own custom frames.
At least one Frame clause is required.
All clauses pertaining to the entire legend (scrollbars, width, etc.) must proceed the first Frame
clause.
The From Layer clause must be the first clause after the Frame clause.
The optional Behind clause places the legend behind the Thematic Map window.
The optional Position clause controls the window's position on MapInfo Pro's workspace. The upper
left corner of MapInfo Pro's workspace has the position 0, 0. The optional Width and Height clauses
control the window's size. Window position and size values use paper units settings, such as "in"
(inches) or "cm" (centimeters). For details about paper units, see Set Paper Units statement.
MapBasic has a current paper units setting, which defaults to inches; a MapBasic program can
change this setting through the Set Paper Units statement. A Create Cartographic Legend
statement can override the current paper units by including the optional Units subclause within the
Position, Width, and/or Height clauses.
Use the ScrollBars clause to show or hide scroll-bars on a Map window.
Portrait or Landscape describes the orientation of the legend frames in the window. Portrait results
in an orientation that is down and across. Landscape results in an orientation that is across and
down.
If Custom is specified, you can specify a custom Position clause for a frame.
The Position clause at the frame level specifies the position of a frame if Custom is specified.The
x coordinate measures from the left of the legend window, and the y coordinate measures from the
bottom of the legend window (the origin (0,0) is in the bottom-left of the legend window).
The optional Style Size clause controls the size of the samples that appear in legend windows. If
you specify Style Size Small, small-sized legend samples are used in Legend windows. If you
specify Style Size Large, larger-sized legend samples are used.
The Position, Title, SubTitle, Border Pen, and Style clauses at the frame level are used only for
map layers. They are not used for thematic layers. For a thematic layer, this information is gotten
automatically from the theme.
The Font clause specifies a text style. If a default frame title, subtitle, or style name font is defined,
then it will become the default for the frame. If a frame level Title, Subtitle, or Style clause exists
and includes a Font clause, then the frame level font is used. If no font is specified at any level,
then the current text style is used and the point sizes are 10, 9, and 8 for title, subtitle and style
name.
The Style clause and the NoRefresh keyword allow you to create custom frames that are not
overwritten when the legend is refreshed. If the NoRefresh keyword is used in the Style clause,
then the table is not scanned for styles. Instead, the Style clause must contain your custom list of
definitions for the styles displayed in the frame. This is done with the Text clause and appropriate
Line, Region, or Symbol clause. Multipoint objects are treated as Point objects.
Collection objects are treated separately. When MapInfo Pro creates a Legend based on object
types, it draws Point symbols first, then Lines, then Regions. Collection objects are drawn last. Inside
collection objects the order of drawing is point, line, and then region samples.
If Column is defined, column is the name of an attribute column in the frame layer's table, or Object
denotes the object column (meaning that legend styles are based on the unique styles in the map
file). The default is Object.
FromMapCatalog ON retrieves styles from the MapCatalog for a live access table. If the table is
not a live access table, MapBasic reverts to the default behavior for a non-live access table instead
of throwing an error. The default behavior for a non-access table is FromMapCatalog Off (for
example, map styles).
FromMapCatalog OFF retrieves the unique map styles for the live table from the server. This table
must be a live access table that supports per record styles for this to occur. If the live table does
not support per record styles than the behavior is to revert to the default behavior for live tables,
which is to get the default styles from the MapCatalog (FromMapCatalog ON).
If a Label is defined, specify expression as a valid expression, or Default (meaning that the default
frame style pattern is used when creating each style's text, unless the style clause contains text).
The default is Default.
Initially, each frame layer's TAB file is searched for metadata values for the title, subtitle, column
and label. If no metadata value exists for the column, the default is Object. If no metadata value
exists for Label, the default is the default frame style pattern. If legend metadata keys exist and you
want to override them, you must use the corresponding MapBasic syntax.
Example
The following example shows how to create a frame for a Map window's cartographic legend. Legend
windows are a special case: To create a frame for a Legend window, you must use the Title clause
instead of the From Window clause.
This creates a frame for a Cartographic Legend window. To create a frame for a Thematic Legend
window, change the title to the following.
See Also:
Set Cartographic Legend statement, Alter Cartographic Frame statement, Add Cartographic
Frame statement, Remove Cartographic Frame statement, Create Legend statement, Set
Window statement, WindowInfo() function
CreateCircle() function
Purpose
Returns an Object value representing a circle. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
CreateCircle( x, y, radius )
x is a float value, indicating the x-position (for example, Longitude) of the circle's center.
y is a float value, indicating the y-position (for example, Latitude) of the circle's center.
radius is a float value, indicating the circle radius.
Return Value
Object
Description
The CreateCircle() function returns an Object value representing a circle.
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.
Note: MapBasic's coordinate system is independent of the coordinate system of any Map window.
The radius parameter specifies the circle radius, in whatever distance unit MapBasic is currently
using. By default, MapBasic uses miles as the distance unit, although the Set Distance Units
statement can re-configure MapBasic to use a different distance unit.
The circle uses whatever Brush style is currently selected. To create a circle object with a specific
Brush, you can issue a Set Style statement before calling CreateCircle(). Alternately, instead of
calling CreateCircle(), you can issue a Create Ellipse statement, which has optional Pen clause
and Brush clause.
The circle object created through the CreateCircle() 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 (using an Insert statement).
Note: Before creating objects on a Layout window, you must issue a Set CoordSys Layout
statement.
Error Conditions
ERR_FCN_ARG_RANGE (644) is generated if an argument is outside of the valid range.
Examples
The following example uses the Insert statement to insert a new row into the table Sites. The
CreateCircle() function is used within the body of the Insert statement to specify the graphic object
that is attached to the new row.
The following example assumes that the table Towers has three columns: Xcoord, Ycoord, and
Radius. The Xcoord column contains longitude values, the Ycoord column contains latitude values,
and the Radius column contains radius values. Each row in the table describes a radio broadcast
tower, and the Radius column indicates each tower's broadcast area.
The Update statement uses the CreateCircle() function to build a circle object for each row in the
table. Following this Update statement, each row in the Towers table will have a circle object attached.
Each circle object will have a radius derived from the Radius column, and each circle will be centered
at the position indicated by the Xcoord and Ycoord columns.
See Also:
Create Ellipse statement, Insert statement, Update statement
Syntax
num_polygons
[ num_points1 ( x1, y1 ) ( x2, y2 ) [ ... ] ]
[ num_points2 ( x1, y1 ) ( x2, y2 ) [ ... ] ... ]
[ Pen... ]
[ Brush... ]
[ Center ( center_x, center_y ) ]
Pline
[ Multiple num_sections ]
num_points
( x1, y1 ) ( x2, y2 ) [ ... ]
[ Pen... ]
[ Smooth... ]
num_parts is the number of non-empty parts inside a collection. This number is from 0 to 3 and is
optional for MapBasic code (it is mandatory for MIF files).
num_polygons is the number of polygons inside the Collection object.
num_sections specifies how many sections the multi-section polyline will contain.
Pen is a valid Pen clause to specify a line style.
Brush is a valid Brush clause to specify fill style.
Example
(3,-2) (4,3)
dim a as object
create collection into variable a multipoint 2 (0,0) (1,1) region 1 3
(1,1) (2,2) (3,4) pline 3 (-1,1) (3,-2) (4,3)
insert into test (obj) values (a)
create collection region 2 4 (-5,-5) (5,-5) (5,5) (-5,5) 4 (-3,-3) (3,-3)
See Also:
Create MultiPoint statement, Set Combine Version statement
provide a set of Target objects, and a set of polylines as a selection object. You can issue this
statement from the MapBasic window in MapInfo Pro.
Syntax
Description
Before using Create Cutter, one or more Polyline objects must be selected, and an editable target
must exist. This is set by choosing the Set Target command, or using the Set Target statement.
The Polyline objects contained in the selection must represent a single, contiguous section. The
Polyline selection must contain no breaks or self intersections.
The Polyline must intersect the Minimum Bounding Rectangle (MBR) of the Target in order for the
Target to be a valid object to split. The Polyline, however, does not have to intersect the Target
object itself. For example, the Target object could be a series of islands (for example, Hawaii), and
the Polyline could be used to divide the islands into two sets without actually intersecting any of the
islands. If the MBR of a Target does not intersect the Polyline, then that Target will be removed from
the Target list.
Given this revised set of Target objects, a cumulative MBR of all of these objects is calculated and
represents the overall space to be split. The polyline is then extended, if necessary, so that it covers
the MBR. This is done by taking the direction of the last two points on each end of the polyline and
extending the polyline in that Cartesian direction until it intersects with the MBR. The extended
Polyline should divide the Target space into two portions. One Region object will be created and
returned which represents one of these two portions.
This statement returns the revised set of Target objects (still set as the Target), as well as this new
Region cutter object. This Region object will be inserted into the Target table (which must be an
editable table). The original Polyline object(s) will remain, but will no longer be selected. The new
Region object will now be the selected object. If the resulting Region object is suitable, then this
operation can be immediately followed by an Object Split operation, as appropriate Target objects
are set, and a suitable Region cutter object is selected.
Note: The cutter object still remains in the target layer. You will have to delete the cutter object
manually from your editable layer.
Example
See Also:
OverlayNodes() function, Set Target statement
Syntax
map_window_id is an integer window identifier which you can obtain by calling the FrontWindow()
function and WindowID() function. If this identifier is for a map within a Layout window, then the
legends are created in the window.
x states the desired distance from the top of the workspace to the top edge of the window.
y states the desired distance from the left of the workspace to the left edge of the window.
Note: Workspace means the client area, which excludes the title bar, tool bar, and the status bar.
legend_window_title is a string expression representing a title for the window, defaults to "Legend
of xxx" where xxx is the map window title.
def_frame_title is a string which defines a default frame title. It can include the special character "#"
which will be replaced by the current layer name.
def_frame_subtitle is a string which defines a default frame subtitle. It can include the special
character "#" which will be replaced by the current layer name.
def_frame_style is a string that displays next to each symbol in each frame. The "#" character will
be replaced with the layer name. The % character will be replaced by the text "Line", "Point, "Region",
as appropriate for the symbol. For example, "% of #" will expand to "Region of States" for the
STATES.TAB layer.
width value, in paper units (see paper_units), is the desired width used to display region sample
swatches within the window.
height value, in paper units (see paper_units), is the desired height used to display region sample
swatches within the window.
frame_text is text for a legend title, subtitle, or descriptive text (such as copyright information for
example).
map_layer_id or map_layer_name identifies a map layer; can be a SmallInt (for example, use 1 to
specify the top map layer other than Cosmetic) or a string representing the name of a table displayed
in the map. For a theme layer you must specify the map_layer_id.
frame_title is a string which defines a frame title. If a Title clause is defined here for a frame, then
it will be used instead of the def_frame_title.
frame_subtitle is a string which defines a frame subtitle. If a Subtitle clause is defined here for a
frame, then it will be used instead of the def_frame_subtitle.
number_of_columns is the number of columns to show in a frame (this is different from the number
of columns in a portrait layout).
frame_height this is used in place of the column clause when the user resizes a legend frame. The
height of the frame in paper units. Written to the WOR when the frame has been manually resized.
column is an attribute column name from the frame layer's table.
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 legend frame embedded in a Layout window.
If a name is assigned to a frame in the Layout, it will be written to the WOR. When the Name clause
is written to the WOR, the workspace version is updated to version 1500.
region_height is a value representing the new height of a swatch in the map frame of the Legend
window. You can specify 8 to 144 points, 0.666667 to 12 picas, 0.111111 to 2 inches, 0.282222 to
5.08 millimeters, or 0.282222 to 5.08 centimeters. If not specified, then the default value of 32 points
is used (which can be set as a preference).
region_width is a value representing the new width of a swatch in the map frame of the Legend
window. You can specify 8 to 144 points, 0.666667 to 12 picas, 0.111111 to 2 inches, 0.282222 to
5.08 millimeters, or 0.282222 to 5.08 centimeters. If not specified, then the default value of 32 points
is used (which can be set as a preference).
line_width is a value representing the new width of a line segment in the map frame of a Legend
window. You can specify 12 to 144 points, 1 to 12 picas, 0.666667 to 2 inches, 4.23333 to 50.8
millimeters, or 4.23333 to 50.8 centimeters. If not specified, then the default value of 36 points is
used (which can be set as a preference).
style_name is a string which displays next to a symbol, line, or region in a custom frame.
Description
The Create Designer Legend statement allows you to create and displays cartographic legends
as well as theme legends for an active map window. Each cartographic and thematic styles legend
will be connected to one, and only one, Map window so that there can be more than one Legend
window open at a time.
You can create a legend frame for each cartographic or thematic map layer you want to include on
the Legend window. Legends can include a legend title and subtitle. They can display a map layer's
styles, or the colors, symbols, and sizes represented by a theme. You can also create legends that
define your own custom styles using the Create Designer Legend statement.
At least one Frame clause is required. Each Frame clause represents one legend that will be created
in the Legend window.
All clauses pertaining to the entire Legend window (width, etc.) must proceed the first Frame clause.
The From Layer clause must be the first clause after the Frame clause.
The optional Behind clause places the legend behind the Map window.
The optional Position clause controls the window's position on MapInfo Pro's workspace. The upper
left corner of MapInfo Pro's workspace has the position 0, 0. The optional Width and Height clauses
control the window's size. Window position and size values use paper units settings, such as "in"
(inches) or "cm" (centimeters). MapBasic has a current paper units setting, which defaults to inches;
a MapBasic program can change this setting through the Set Paper Units statement. A Create
Designer Legend statement can override the current paper units by including the optional Units
subclause within the Position, Width, and/or Height clauses.
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.
Border 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.
The Region Height clause specifies a specific height for a swatch in the legend frame of the Legend
window.
The Region Width clause specifies a specific width for a swatch in the legend frame of the Legend
window.
The Line Width clause specifies a specific width for a line sample in the legend frame of the Legend
window.
Auto Font Size enables or disables resizing the legend swatch based on the font size setting.
Portrait or Landscape describes the orientation or automatic arrangement of the legend frames in
the window. Portrait results in an orientation that is down and across. Landscape results in an
orientation that is across and down.
If Custom is specified, you can specify a custom Position clause for each frame.
The Position clause at the frame level specifies the position of a frame if Custom is specified.The
x coordinate measures from the left of the Legend window, and the y coordinate measures from
the bottom of the Legend window (the origin (0,0) is in the bottom-left of the Legend window).
The Position, Default Frame Title, Default Frame SubTitle, and Default Frame Style clauses at
the frame level are used only for map layer legends. They are not used for thematic layer legends.
For a thematic legend, this information is obtained automatically from the theme.
The default frame settings are optional. If not specified, then the default is used from the application
preferences (minimum and maximum limits will exist). The new swatch settings will override the
default frame settings.
• The Default Frame Line Width is width in paper units for line style samples.
• The Default Frame Region Width is width in paper units for region style samples.
• The Default Frame Region Height is height in paper units for region style samples.
paper_units is a string representing a paper unit name. For details about paper units, see Set Paper
Units statement.
Legend Text Frame creates a text frame in the Legend window.
If Text does not specify the Font clause, then the default font is used.
If Column is defined, column is the name of an attribute column in the frame layer's table, or Object
denotes the object column (meaning that legend styles are based on the unique styles in the map
file). The default is Object.
FromMapCatalog ON retrieves styles from the MapCatalog for a live access table. If the table is
not a live access table, MapBasic reverts to the default behavior for a non-live access table instead
of throwing an error. The default behavior for a non-access table is FromMapCatalog Off (for
example, map styles).
FromMapCatalog OFF retrieves the unique map styles for the live table from the server. This table
must be a live access table that supports per record styles for this to occur. If the live table does
not support per record styles than the behavior is to revert to the default behavior for live tables,
which is to get the default styles from the MapCatalog (FromMapCatalog ON).
If a Label is defined, specify expression as a valid expression, or Default (meaning that the default
frame style pattern is used when creating each style's text, unless the style clause contains text).
The default is Default.
The Height clause is used in place of the Columns clause when the user resizes a frame. This
applies to both map legend frames and thematic legend frames, which are mutually exclusive. If
both are present, then the Columns clause is used.
The Order clause adds the ability to sort or customize the order of rows in map legends. You can
sort map legends by style label or by defining your own order. The sort order options are Default,
Ascending, Descending, or Custom. The Order clause is only written to a workspace if the map
legend is sorted ascending, descending, or custom.
A Default sort order is the order the Create Legend wizard creates the legend rows. If you create
a legend based on unique styles, this will be the order of those styles, which then display as rows
in the map legend.
If specifying Custom sort order, the id values are row ids starting with 1, moving from top to bottom.
When looking at the list of rows in the Legend Frame Properties dialog box, the first row in the list
has id equal to 1 and so on down the list. For more details, see Custom Order Options and the
Alter Designer Frame statement custom order Options.
The Display clause controls the display of each row. Each row in MapBasic starts with the Style
clause. At the end of each Style clause is the optional Display clause. Display On makes the row
visible. Display Off makes the row invisible. If the Display clause is absent, then the row displays.
The Display clause is only written to a workspace file for styles that are not visible in a legend frame.
Note: The Shade statement and Set Legend statement still create and modify thematic legends,
but only the Create Designer Legend statement adds thematic legends to a Legend window
(by specifying the theme layer ID using the Frame From Layer id clause).
Note: The Columns or Height clauses apply to map and thematic legends. However, all other
thematic legend properties must be specified using the Set Legend statement.
The Style clause and the NoRefresh keyword allow you to create custom frames that are not
overwritten when the legend is refreshed. If the NoRefresh keyword is used in the Style clause,
then the table is not scanned for styles. Instead, the Style clause must contain your custom list of
definitions for the styles displayed in the frame. This is done with the Text clause and appropriate
Line, Region, or Symbol clause. Multipoint objects are treated as Point objects.
Collection objects are treated separately. When MapInfo Pro creates a Legend based on object
types, it draws Point symbols first, then Lines, then Regions. Collection objects are drawn last. Inside
collection objects the order of drawing is point, line, and then region samples.
The Font clause specifies a text style. If a default frame title, subtitle, or style name font is defined,
then it will become the default for the frame. If a frame level Default Frame Title, Default Frame
Subtitle, or Default Frame Style clause exists and includes a Font clause, then the frame level
font is used. If no font is specified at any level, then the font styles in the Legend Window preferences
are used for title, subtitle, and style name.
Initially, each frame layer's TAB file is searched for metadata values for the title, subtitle, column
and label. If no metadata value exists for the column, the default is Object. If no metadata value
exists for Label, the default is the default frame style pattern. If legend metadata keys exist and you
want to override them, you must use the corresponding MapBasic syntax. See GetMetadata$()
function and Metadata statement.
Some of the clauses in the Create Designer Legend statement syntax do not apply when creating
a legend frame for a map embedded within a Layout window. The Behind, Window Title, and
Legend Text Frame clauses are ignored.
If you use the Create Designer Legend statement again for the same map in a Layout window, you
will see a message stating that the map already contains one or more legends. Use the Add Designer
Frame statement instead.
Example
See Also:
Alter Designer Frame statement, Add Designer Frame statement, Remove Designer Frame
statement, Set Designer Legend statement, Set Window statement, WindowInfo() function
Custom id | id : id [ , id | id : id ... ]
Where the following specifies a range of row ids in increasing order (Id2 > Id1):
Id1 : Id2
Reordering a List
The syntax for custom order of legend rows is similar to the Order clause (to reorder layers) in the
Set Map statement. It is fairly easy to use when you want to reorder near the beginning of a list,
but not so easy when you want to reorder near the end. For instance, if you want to reverse the
order of the first three rows you only have to use:
Order Custom 3, 2, 1
You can leave out the rest of the rows. If you have 10 rows and want to switch the last two, you
have to list all the ids like this:
Long form:
Order Custom 2, 5, 6, 7, 8, 9, 10, 1, 3, 4
Short form:
Order Custom 2, 5:10, 1, 3, 4
Order Custom 2, 5:10, 1, 3:4 (same as above but also valid)
Order Custom 2, 5:10, 1 (same as above but also valid)
Long form:
Order Custom 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18,
19, 20, 11
Short form:
Order Custom 1:10, 12:20, 11
The list of values cannot have duplicates that will cause an error. The following causes an error:
This is because row ids 4 and 5 are duplicates. To see this, expand the syntax as follows (which
causes an error):
Order Custom 1, 2, 3, 4, 5, 8, 4, 5, 6, 7
The alternate syntax can be used when creating or altering a legend in the Legend window. For
workspaces, the short syntax is used when legends in the Legend window have more than 50 rows
with a custom order.
Syntax
Create Ellipse
[ Into { Window window_id | Variable var_name } ]
( x1, y1 ) ( x2, y2 )
[ Pen... ]
[ Brush... ] [ Priority n ] [ Name framename ]
Description
The Create Ellipse statement creates an ellipse or circle object. If the object's Minimum Bounding
Rectangle (MBR) is defined in such a way that the x-radius equals the y-radius, the object will be a
circle; otherwise, the object will be an ellipse.
If the statement includes the optional Into Variable clause, the object will be stored in the specified
object variable. If the Into clause specifies a window identifier, the object will be stored in the
appropriate place in the window (for example, in the editable layer of a Map window). If the Into
clause is not provided, MapBasic attempts to store the object in the topmost window; if objects may
not be stored in the topmost window (for example, if the topmost window is a grapher) no object will
be created.
The x and y parameters use whatever coordinate system MapBasic is currently using. By default,
MapBasic uses a Latitude/Longitude coordinate system, although the Set CoordSys statement
can re-configure MapBasic to use a different coordinate system. Note that MapBasic's coordinate
system is independent of the coordinate system of any Map window. Objects created on a Layout
window, however, are specified in paper units: each x-coordinate represents a distance from the
left edge of the page, while each y-coordinate represents the distance from the top edge of the
page. For details about paper units, see Set Paper Units statement. By default, MapBasic uses
inches as the default paper unit. To use a different paper unit, use the Set Paper Units statement.
Before creating objects on a Layout window, you must issue a Set CoordSys Layout statement.
The optional Pen clause specifies a line style. If no Pen clause is specified, the Create Ellipse
statement uses the current MapInfo Pro line style (the style which appears in the Line Style dialog
box). Similarly, the optional Brush clause specifies a fill style.
When creating a clone statement or saving a workspace, MapInfo Pro normalizes the priority of
frames to a unique set of values beginning with one (1). Use the Priority clause to assign the Z-Order
of the newly created object frame on the Layout window.
The Name clause assigns a name to a frame in the Layout window. If a name is assigned, it is
written to the workspace (WOR) file and the workspace version updates to 1500.
See Also:
Brush clause, CreateCircle() function, Insert statement, Pen clause, Update statement
Syntax
Create Frame
[ Into { Window window_id | Variable var_name } ]
( x1, y1 ) ( x2, y2 )
[ Pen... ]
[ Brush... ]
[ Priority n ]
[ Name framename ]
[ Title title ]
Description
The Create Frame statement creates a new frame within an existing layout window. This statement
works with both Layout windows and the older (classic) Layout windows. If no window_id is specified,
the new frame is added to the topmost layout window.
If you use non-Earth coordinate (X, Y) values to position the frame, an error displays. Before creating
objects on a layout, you must issue a Set CoordSys Layout statement.
The window_id parameter specifies which layout window to add a new frame to and the
contents_win_id parameter specifies which window will appear in the new frame. 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.
Frames in a Layout window cannot be in a negative position past the top or past the left edge of
the layout. MapInfo Pro adjusts a negative X or Y value to make it zero (0) when placing the frame.
(The classic Layout window does allow negative position values.)
The Pen clause dictates what line style will be used to display the frame, and the Brush clause
dictates the fill style used to fill the frame window.
The Title clause provides an alternate syntax for specifying which window appears in the frame.
For example, to identify a Map window that displays the table WORLD, the Title clause should read
Title "WORLD Map". If the title string does not refer to an existing window, or if title is an empty
string (""), the frame will be empty. If you specify both the Title clause and the From Window
clause, the latter clause takes effect.
Use the From Window clause to specify which window should appear inside the frame. For example,
to make a Map window appear inside the frame, specify From Window id_map (where id_map is
an integer variable containing the Map window identifier). A window must already be open before
you can create a frame containing the window.
The FillFrame clause controls how the window fills the frame. If you specify FillFrame On, the
entire frame is filled with an image of the window. If you specify FillFrame Off (or if you omit the
FillFrame clause entirely), the aspect ratio of the window affects the appearance of the frame; in
other words, re-sizing a Map window to be tall and thin causes the frame to appear tall and thin.
Between sessions, MapInfo Pro preserves layout window settings by storing Create Frame
statements in the workspace file. To see an example of the Create Frame statement, create a
layout, save the workspace, and examine the workspace file in a text editor.
Note: When working with an existing layout, you can get the window ID of a map frame in the
layout by calling the LayoutItemInfo() function with the LAYOUT_ITEM_INFO_WIN attribute.
Example
The following examples show how to create a frame for a Map window's thematic legend, or
Cartographic Legend window.
Theme Legend windows are a special case. To create a frame for a Theme Legend window, you
must use the Title clause instead of the From Window clause.
To create a frame for a Map window's cartographic legend, you should use the From Window
clause since there may be more than one cartographic legend window per map.
Create Frame
Into Window i_layout_id
(1,2) (4, 5)
From Window i_cartlgnd_id
See Also:
Brush clause, Insert statement, Layout statement, Pen clause, Set CoordSys statement, Set
Layout statement, Update statement
Syntax
Create Frame
[ Into { Window window_id | Variable var_name } ]
( x1, y1 ) ( x2, y2 )
[ Pen... ]
[ Brush... ]
[ Priority n ]
[ Name framename ]
If window_id refers to a Layout window, a new empty frame will be created. If it refers to a classic
Layout window, the legacy empty frame will still be created.
If Name is omitted the default text will be "" (empty string). Names will be displayed in the center of
the frame. Long names (names wider than the current width of the empty frame) will wrap.
If Pen is omitted default pen will be a single pixel solid black line.
If Brush is omitted default brush will be a transparent brush (no fill).If Priority is omitted the frame
is added as the topmost.
The empty frame is counted as a frame like any other and added to the frame count returned by
LayoutInfo().The Pen, Brush, Name, and Priority properties can be modified after the frame is created
using Alter Designer Frame statement. Position and size can also be modified using Alter Designer
Frame or by clicking and dragging the frame in the GUI. The frame border and fill (pen and brush)
can be modified in the GUI using the Frame Properties dialog.
If ID is an empty frame, then when followed by From Window clause, the empty frame is populated
by a clone of the original map or browser.
2. Using the Map From and Browse From statements
Use these statements to insert currently open tables into the empty frame. For example,
This will create a map for the open tables called World and World_Cities and insert it into the
empty frame in the Layout Designer window. A default view of the map will be displayed. The
frame properties already set for the empty frame will also be retained (pen, brush, position, size,
name, and z-order).
This leaves an empty frame of the same size and position as the content it just contained, and
retains the name currently assigned to it. The content itself is destroyed; meaning, the map or
browser goes away. Other frame properties such as the border pen, fill brush, and z-order remain
unchanged.
Browsers, Maps, Legends, Shapes, Images, and Text can be removed using this command. The
command can also be used on an empty frame. If you clear a Map frame and it has legend frames
associated with it, the legend frames will be removed from the layout.
Syntax
Create Grid
From tablename
With expression [ Ignore value_to_ignore ]
tablename is the "alias" name of an open table from which to get data points.
expression is the expression by which the table will be shaded, such as a column name.
value_to_ignore is a value to be ignored; this is usually zero. No grid theme will be created for a
row if the row's value matches the value to be ignored.
filespec specifies the fully qualified path and name of the new grid file. It will have a .MIG extension.
grid_type is a string expression that specifies the type of grid file to create. By default, .MIG format
files are created using "mig.ghl". If using a custom grid handler, then supply the name of that custom
grid handler, such as "dted.ghl".
Coordsys is an optional CoordSys clause which is the coordinate system that the grid will be created
in. If not provided, the grid will be created in the same coordinate system as the source table. Refer
to CoordSys clause for more information.
obj is an object to clip grid cells to. Only the portion of the grid theme within the object will display.
If a grid cell is not within the object, that cell value will not be written out and a null cell is written in
its place.
tablename is the name of a table of region objects which will be combined into a single region object
and then used for clipping grid cells.
num_inflections is a numeric expression, specifying the number of color:inflection_value pairs.
color is a color expression of, part of a color:value inflection pair.
inflection_value is a numeric expression, specifying the value of a color:inflection_value pair as a
number or a percentage.
rounding_factor is a numeric expression, specifying the rounding factor applied to the inflection
values.
cell_size is a numeric expression, specifying the size of a grid cell in distance units.
distance_unit is a string expression specifying the units for the preceding cell size. This is an optional
parameter. If not present, the distance units from the table's coordinate system are used.
n_cells is a numeric expression that specifies the height or width of the grid in cells only.
numcells defines the number of cells to be added around the edge of the original grid bounds.
numcells will be added to the left, right, top, and bottom of the original grid dimensions.
interpolator_name is a string expression specifying the name of the interpolator to use to create the
grid. MapInfo built-in interpolators are "IDW" or "TIN."
version_string is a string expression specifying the version of the interpolator that the parameters
are meant for. (Version 100 of the IDW interpolator shipped with MapInfo Pro 5.0 and Version 200
of the TIN and IDW interpolators shipped with MapInfo Pro 5.5 and later.)
num_parameters is a numeric expression, that specifies the number of parameter_name:
parameter_value pairs to use.
• parameter_name is a string expression, specifying the name part of this pair.
• parameter_value is a numeric expression, specifying the value part of this pair.
Description
A grid surface theme is a continuous raster grid produced by an interpolation of point data. The
Create Grid statement takes a data column from a table of points, and passes those points and
their data values to an interpolator. The interpolator produces a raster grid file, which MapBasic
displays as a raster table in a Map window.
The Create Grid statement reads (x, y, z) values from the table specified in the From clause. It gets
the z values by evaluating the expression specified in the With clause with respect to the table.
The dimensions of the grid can be specified in two ways. One is by specifying the size of a grid cell
in distance units, such as miles. The other is by specifying a minimum height or width of the grid in
terms of grid cells. For example, if you wanted the grid to be at least 200 cells wide by 200 cells
high, you would specify "cell min 200". Depending on the aspect ratio of the area covered by the
grid, the actual grid dimensions would not be 200 by 200, but it would be at least that wide and high.
By Percent at specifies that the subsequent color:Inflection_value pairs represent a color value
and Percentage value. If not used, then the Inflection_value represents a numeric value such as
elevation or temperature.
For more about grids, see Grid Description. For details about specific interpolators, see IDW
Interpolator, and TIN Interpolator.
Example
create grid
from Us_elev
with Elevation_FT
into "C:\Us_elev_grid"
clipping table States
inflect 5 at
RGB(0, 0, 255) : 13
RGB(0, 255, 255) : 3632.5
RGB(0, 255, 0) : 7252
RGB(255, 255, 0) : 10871.5
RGB(255, 0, 0) : 14491
cell min 200
interpolate
with "IDW" version "100"
using 4
"EXPONENT": "2"
"MAX POINTS": "25"
"MIN POINTS": "1"
"SEARCH RADIUS": "100"
See Also:
GetGridCellValue() function, GridTableInfo(), IsGridCellNull() function, OverlayNodes() function,
RasterTableInfo() function, Set Map statement
Grid Description
A grid surface theme is a continuous raster grid produced by an interpolation of point data. The
Create Grid statement takes a data column from a table of points and passes those points and their
data values to an interpolator. The interpolator produces a raster grid file, which MapBasic displays
as a raster table in a Map window. The Create Grid statement reads (x, y, z) values from the table
specified in the From tablename clause. It gets the z values by evaluating the expression specified
in the With clause (a column name) with respect to the table and computes a grid cell value using
the settings provided for the specific interpolator chosen with these points.
The dimensions of the grid can be specified in two ways. One is by specifying the size of a grid cell
in distance units, such as miles, meters, feet, and so on. The other is by specifying a minimum
height or width of the grid by number of grid cells. For example, if you wanted the grid to be at least
200 cells wide by 200 cells high, you would specify "cell min 200". Depending on the aspect ratio
of the area covered by the grid, the actual grid dimensions might not be exactly 200 by 200, but it
would be at least that wide and high.
Example IDW Interpolation with inflections set at certain elevation values:
From Us_elev
with Elevation_FT
ignore 0
into "C:\ MapData\Us_elev_grid.mig"
Type "mig.ghl"
CoordSys Earth Projection 1, 74
clipping table States
Inflect 6 at
RGB(64, 0, 128) : -32808
RGB(0, 128, 192) : -16404
RGB(151, 255, 239) : -98
RGB(254, 248, 199) : 33
RGB(244, 171, 100) : 6566
RGB(235, 95, 1) : 32808
round 100
cell min 200
interpolate
with "IDW" version "100"
using 7
"AGGREGATION METHOD": "1"
"BORDER": "0"
"CELL SIZE": "8"
"EXPONENT": "2"
"MAX POINTS": "25"
"MIN POINTS": "1"
"SEARCH RADIUS": "800"
inflect 5 by Percent at
RGB(0, 0, 255) : 0
RGB(0, 255, 255) : 25
RGB(0, 255, 0) : 50
RGB(255, 255, 0) : 75
RGB(255, 0, 0) : 100
Round 10
cell min 200
interpolate
with "TIN" version "100"
using 8
"BORDER": "0"
"CELL SIZE": "15"
"DISTANCE": "80"
"EXPONENT": "2"
"FEATURE ANGLE": "45"
"SEARCH RADIUS": "53"
"TOLERANCE": "0.01 "
"READ ONLY": "T"
Grid Templates
When creating a Grid thematic map in MapInfo Pro, the Grid default template assigns blue to the
minimum value and red to the maximum value. These minimum and maximum values are also
expressed as percentages of the range. These color settings/values are known as inflection points
and will display in the legend with a particular color, value and percentage. If a cell has the exact
value as the inflection point, it will display that color on the map. A cell value that falls between two
inflection points displays with the color that is in between the colors of those inflection points.
See Also:
IDW Interpolator, TIN Interpolator
IDW Interpolator
The IDW Interpolator is best suited for data values that produce arbitrary values over the grid, that
is, data that does not have any relationship or influence over neighboring data values, such as
population. This method of interpolation also works well for sparse data. The IDW Interpolator
calculates the value of grid cells that cover the mapping area. Each data point value from the source
table that is considered in the calculation for a cell value is weighted by its distance from the center
of the cell. Because the interpolation is an inverse distance weighting calculation, the farther the
point is from the cell, the less influence its value will have on the resulting cell value. MapInfo Pro's
grid mapping process begins by determining the minimum bounding rectangle (MBR) of the source
table. The grid is divided into equal sized square cells of some size. For example, using the Grid
default template, the States table in MapInfo Pro's sample data set creates a grid dimension of 200
cells by 303 cells. By calculating the number of cells in the grid and knowing the dimension of the
MBR, MapInfo Pro determines that each cell needs to be 18.1 by 18.1 miles square. (The cell size
will be in whatever distance units set for the Map window. To change the units, select Map >
Options > Map Units.)
The IDW Interpolator settings can be controlled via the Settings button in the Create Thematic
Map - Step 3 of 3 dialog when creating a grid thematic map. The cell size number in this interpolator
settings dialog represents both the height and width of the cell. Any change to the cell size will result
in an automatic update of the grid dimensions. With the cell size and the source points and values
known, MapInfo Pro calculates a value for each cell. This value is determined by calculating a
distance-weighted average of the points that lie within the specified search radius. Points are inversely
weighted by their distance from the center of the cell. In the IDW Interpolator, the exponent determines
how much influence each point will have on the result. The higher the exponent, the greater the
influence closer points will have on the cell value. Exponents can range from one to 10. You can
also choose an aggregation method for the z-values of coincident source data points (ones that fall
within area of same grid cell). Coincident data points can be aggregated by average, count, sum,
min, and max. Average method is aggregation default.
correspond to controls in the interpolator settings dialog box. Instead of passing a string for
aggregation, however, a number will be used.
Average 0
Count 1
Minimum 2
Maximum 3
Sum 4
If parameter name : parameter is not provided, then a default value is used. If all default interpolator
settings are desired, then set Using num_parameters to 0.
See Also:
Create Grid statement, READ ONLY Parameter for TIN and IDW Interpolators
TIN Interpolator
The TIN Interpolator works best for terrain data and for data points that have a linear progression
or relationship to each other across the grid, such as elevation or temperature. The TIN Interpolator
produces triangles from a network of points that more closely reproduces the original map terrain
than the IDW Interpolator. It draws lines between points, dividing them into triangles and connecting
all the points that it can. It creates a mesh of connectivity so that the grid points can be interpolated.
The interpolation is not influenced by the neighboring original data values, so you do not get the
"false bumping" of data that you can get with the IDW Interpolator.
The TIN settings can be manipulated to give more or less detail to the map terrain. The Tolerance
setting controls whether closely spaced points are discarded. The tolerance is a fraction of the
diagonal length of the bounding box of the points. The Distance value controls the output. For
non-zero distance values, only edges or triangles contained within a sphere centered at mesh
vertices are output. This is useful to constrain the triangulated irregular network to a specified
distance; otherwise, the triangulation will cross concave regions. The Feature Angle setting controls
the angle (in degrees) that defines a sharp edge. This setting is used for smoothing the final grid.
If the difference in angle across neighboring polygons is greater than this value, the shared edge
is considered "sharp."
The TIN Interpolator settings can be controlled via the Settings button in the Create Thematic Map
- Step 3 of 3 dialog when creating a grid thematic map. The cell size number in this interpolator
settings dialog represents both the height and width of the cell like the IDW method. Any change to
the cell size will result in an automatic update of the grid dimensions.
See Also:
READ ONLY Parameter for TIN and IDW Interpolators
is written into the TAB file and the user will not be able to modify or re-interpolate the grid via the
user interface.
Syntax
Description
The Create Index statement creates an index on the specified column. MapInfo Pro uses Indexes
in operations such as Find. Indexes also improve the performance of queries in general.
Note: MapInfo Pro cannot create an index if the table has unsaved edits. Use the Commit Table
statement to save edits.
Example
The following example creates an index for the "Capital" field of the World table.
See Also:
Alter Table statement, Create Table statement, Drop Index statement, Commit Table statement
Syntax
Create Legend
[ From Window window_ID ]
[ { Show | Hide } ]
Description
This statement creates a special floating, Thematic Legend window, in addition to the standard
MapInfo Pro Legend window. (To open MapInfo Pro's standard Legend window, use the Open
Window Legend statement.)
The Create Legend statement is useful if you want the Legend of a Map window to always be
visible, even when the Map window is not active. Also, this statement is useful in "Integrated Mapping"
applications, where MapInfo Pro windows are integrated into another application, such as a Visual
Basic application. For information about Integrated Mapping, see the MapBasic User Guide.
If you include the From Window clause, the new Theme Legend window is tied to the window that
you specify; otherwise, the new window is tied to the most recently used Map.
If you include the optional Hide keyword, the window is created in a hidden state. You can then
show the hidden window by using the Set Window...Show statement.
After you issue the Create Legend statement, determine the new window's integer ID by calling
WindowID( 0 ). Use that window ID in subsequent statements (such as the Set Window
statement).
The new Theme Legend window is created according to the parent and style settings that you specify
through the Set Next Document statement.
See Also:
Create Cartographic Legend statement, Open Window statement, Set Next Document
statement, Set Window statement
CreateLine() function
Purpose
Returns an Object value representing a line. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
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.
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.
See Also:
Create Line statement, Insert statement, Update statement
Syntax
Create Line
[ Into { Window window_id | Variable var_name } ]
( x1, y1) ( x2, y2)
[ Pen... ] [ Priority n ] [ Name framename ]
Description
The Create Line statement creates a line object.
If the statement includes the optional Into Variable clause, the object will be stored in the specified
object variable. If the Into clause specifies a window identifier, the object will be stored in the
appropriate place in the window (for example, in the editable layer of a Map window). If the Into
clause is not provided, MapBasic will attempt to store the object in the topmost window; if objects
may not be stored in the topmost window (for example, if the topmost window is a grapher) no object
will be created.
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. Note that MapBasic's coordinate
system is independent of the coordinate system of any Map window. Objects created on a Layout
window, however, are specified in paper units: each x-coordinate represents a distance from the
left edge of the page, while each y-coordinate represents the distance from the top edge of the
page. For details about paper units, see Set Paper Units statement. By default, MapBasic uses
inches as the default paper unit. To use a different paper unit, use the Set Paper Units statement.
Note: If you need to create objects on a Layout window, you must first issue a Set CoordSys
Layout statement.
The optional Pen clause specifies a line style; see Pen clause for more details. If no Pen clause
is specified, the Create Line statement will use the current MapInfo Pro line style.
When creating a clone statement or saving a workspace, MapInfo Pro normalizes the priority of
frames to a unique set of values beginning with one (1). Use the Priority clause to assign the Z-Order
of the newly created object frame on the Layout window.
The Name clause assigns a name to a frame in the Layout window. If a name is assigned, it is
written to the workspace (WOR) file and the workspace version updates to 1500.
See Also:
CreateLine() function, Insert statement, Pen clause, Update statement
Syntax
Create Map
For table [ BlockSize block_size ]
[ CoordSys... ] Using from_table]
Description
The Create Map statement makes an open table mappable, so that it can be displayed in a Map
window. This statement does not open a new Map window. To open a new Map window, use the
Map statement.
You should not perform a Create Map statement on a table that is already mappable; doing so
will delete all map objects from the table. If a table already has a map attached, and you wish
to permanently change the projection of the map, use a Table As statement. Alternately, if you
wish to temporarily change the projection in which a map is displayed, issue a Set Map statement
with a CoordSys clause. The Create Map statement does not work on linked tables. To make a
linked table mappable, use the Server Create Map statement.
The BlockSize clause have a value of zero (0) to 32768. If not specified, the default is 16384. If the
value is less than 512, it rounds up to 512. Generally, the larger the block size, the faster the data
transfer rate. When converting from NativeX (MapInfo Extended) format to Native (MapInfo) format,
the original block size of the NativeX file is preserved. Users can specify a new block size when
committing from NativeX to Native format.
CoordSys is a coordinate system clause; see CoordSys clause and refer to the next section,
Specifying the Coordinate System.
• Explicitly supply the coordinate system information through a CoordSys clause (set in preferences).
If you omit both the CoordSys clause and the Using clause, the table will use the current MapBasic
coordinate system.
Note that the CoordSys clause affects the precision of the map. The CoordSys clause includes
a Bounds clause, which sets limits on the minimum and maximum coordinates that can be stored
in the map. If you omit the Bounds clause, MapInfo Pro uses default bounds that encompass the
entire Earth (in which case, coordinates are precise to one millionth of a degree, or approximately
4 inches). If you know in advance that the map you are creating is limited to a finite area (for example,
a specific metropolitan area), you can increase the precision of the map's coordinates by specifying
bounds that confine the map to that area. For a complete listing of the CoordSys syntax, see
CoordSys clause.
See Also:
Commit Table statement, CoordSys clause, Create Table statement, Drop Map statement,
Map statement, Server Create Map statement, Set Map statement
Syntax
Create Map3D
[ From Window window_id | MapString mapper_creation_string ]
[ Camera [ Pitch angle | Roll angle | Yaw angle | Elevation angle ] |
[ Position ( x, y, z ) | FocalPoint ( x, y, z ) ] |
[ Orientation ( vu_1, vu_2, vu_3, vpn_1, vpn_2, vpn_3,
clip_near, clip_far )]]
[ Light [ Position ( x, y, z ) | Color lightcolor ] ]
[ Resolution ( res_x, res_y ) ]
[ Scale grid_scale ]
[ Background backgroundcolor ]
[ Units unit_name ]
window_id is a window identifier a for a Map window which contains a Grid layer. An error message
is displayed if a Grid layer is not found.
mapper_creation_string specifies a command string that creates the mapper textured on the grid.
Camera specifies the camera position and orientation.
angle is an angle measurement in degrees. The horizontal angle in the dialog box ranges from
0-360 degrees and rotates the maps around the center point of the grid. The vertical angle in the
dialog box ranges from 0-90 and measures the rotation in elevation from the start point directly over
the map.
Pitch adjusts the camera's current rotation about the x axis centered at the camera's origin.
Roll adjusts the camera's current rotation about the z axis centered at the camera's origin.
Yaw adjusts the camera's current rotation about the y axis centered at the camera's origin.
Elevation adjusts the current camera's rotation about the x axis centered at the camera's focal
point.
Position indicates the camera/light position.
FocalPoint indicates the camera/light focal point.
Orientation specifies the cameras ViewUp (vu_1, vu_2, vu_3), ViewPlane Normal (vpn_1, vpn_2,
vpn_3), and Clipping Range (clip_near, clip_far) (used specifically for persistence of view).
Resolution is the number of samples to take in the x and y directions. These values can increase
to a maximum of the grid resolution. The resolution values can increase to a maximum of the grid
x, y dimension. If the grid is 200x200 then the resolution values will be clamped to a maximum of
200x200. You cannot increase the grid resolution, only specify a subsample value.
grid_scale is the amount to scale the grid in the z direction. A value >1 will exaggerate the topology
in the z direction, a value <1 will scale down the topological features in the z direction.
backgroundcolor is a color to be used to set the background and is specified using the RGB()
function.
unit_name specifies the units the grid values are in. Do not specify this for unit-less grids (for example,
grids generated using temperature or density). This option needs to be specified at creation time.
You cannot change them later with the Set Map3D statement or the Properties dialog box.
Description
Once it is created, the 3DMap window is a standalone window. Since it is based on the same tables
as the original Map window, if these tables are changed and the 3DMap window is manually
"refreshed" or re-created from a workspace, these changes are displayed on the grid. The creation
fails if the window_id is not a Map window or if the Map window does not contain a Grid layer. If
there are multiple grids in the Map window, each will be represented in the 3DMap window.
A 3DMap keeps a Mapper creation string as its texture generator. This string will also be prevalent
in the workspace when the 3DMap window is persisted. The initialization will read in the grid layer
to create 3D geometry and topology objects.
Example
Creates a 3DMap window of the most recent Map window. It will fail if the window does not contain
any Continuous Grid layers. Another example is:
Creates a 3DMap window with a Red background, the z units set to feet, a Z scale factor of 2, and
the grid resolution set to 100x100.
See Also:
Set Map3D statement
Syntax 1
Syntax 2
Note: In MapInfo Pro 64-bit, Syntax 2 above would remove the menu from the menu group.
Description
If the newmenuname parameter matches the name of an existing MapInfo Pro menu (such as File),
the statement re-defines that menu. If the newmenuname parameter does not match the name of
an existing menu, the Create Menu statement defines an entirely new menu. For a list of the standard
MapInfo Pro menu names, see Alter Menu statement.
The Create Menu statement does not automatically display a newly-created menu; a new menu
will only display as a result of a subsequent Alter Menu Bar statement or Create Menu Bar
statement. However, if a Create Menu statement modifies an existing menu, and if that existing
menu is already part of the menu bar, the change will be visible immediately.
Note: MapInfo Pro can maintain no more than 96 menu definitions at one time, including the menus
defined automatically by MapInfo Pro (File, etc.). This limit is independent of the number of
menus displayed on the menu bar at one time.
The menuitem parameter identifies the name of the menu item. The item's name can contain special
control characters to define menu item attributes (for example, whether a menu item is checkable).
See tables below for details.
The following characters require special handling: slash (/), back slash(\), and less than (<). If you
want to display any of these special characters in the menu or the status bar help, you must include
an extra back slash in the menuitem string or the help string. For example, the following statement
creates a menu item that reads, "Client/Server."
If a menuitem parameter begins with the character @, the custom menu breaks into two columns.
The item whose name starts with @ is the first item in the second column.
Things to remember when using this command with the MapInfo Pro 64-bit:
1. If the menu with the id already exist in the Legacy tab then all the user addin controls from that
menu would we removed and the menu would be created with new structure.
associated with it, that menu item is inert. Inert menu items are used for cosmetic purposes, such
as displaying horizontal lines which break up a menu.
When you add a hierarchical menu to the menu, the name of the hierarchical menu appears on the
parent menu instead of the menuitem string.
The menu item is a horizontal separator line; such a menu item cannot have a handler. Example:
(- (-
This special code represents the File menu's most-recently-used (MRU) list. It may only appear
($ once in the menu system, and it may not be used on a shortcut menu. To eliminate the MRU
list from the File menu, either delete this code from MAPINFOW.MNU or re-create the File
menu by issuing a Create Menu statement.
This special code represents the Window menu's list of open windows. It may only appear once
(> in the menu system.
If a caret (^) appears within the text string of a checkable menu item, the item toggles between
! ... ^ ... alternate text (for example, Show... vs. Hide...) instead of toggling between checked
and unchecked. The text before the caret appears when the item is "checked." Example: !Hide
Status Bar^Show Status Bar
Note: The codes in the following tables must appear at the end of a menu item name.
Defines a Windows shortcut key which also requires the Shift key.
/W# {letter | %number}
Examples: Zap /W#Z or Zap /W#%120
Defines a Windows shortcut key which also requires the Alt key.
/W@ {letter | %number}
Examples: Zap /W@Z or Zap /W@%120
Defines a Windows shortcut key which also requires the Ctrl key.
/W^ {letter | %number}
Examples: Zap /W^Z or Zap /W^%120
To specify a function key as a Windows accelerator, the accelerator code must include a percent
sign (%) followed by a number. The number 112 corresponds to F1, 113 corresponds to F2, etc.
Note: The Create Menu Bar As Default statement removes and un-defines all custom menus
created through the Create Menu statement. Alternately, if you need to un-define one, but
not all, of the custom menus that your application has added, you can issue a statement of
the form Create Menu menuname As Default.
After altering a standard MapInfo Pro menu (for example, "File"), you can restore the menu to its
original state by issuing a Create Menu menuname As Default statement.
In the last two cases, the string sent to OLE or DDE starts with the three letters "MI:" (so that the
server can detect that the message came from MapInfo Pro). The remainder of the string contains
a comma-separated list of the values returned from relevant CommandInfo() function calls. For
complete details on the string syntax, see the MapBasic User Guide.
Examples
The following example uses the Create Menu statement to create a custom menu, then adds the
custom menu to MapInfo Pro's menu bar. This example removes the Window menu (ID 6) and the
Help menu (ID 7), and then adds the custom menu, the Window menu, and the Help menu back to
the menu bar. This technique guarantees that the last two menus will always be Window, and Help.
The following example creates an abbreviated version of the File menu. The "(" control character
specifies that the Close, Save, and Print options will be disabled initially. The Open and Save
options have Windows accelerator key sequences (Ctrl+O and Ctrl+S, respectively). Note that both
the Open and Save options use the Chr$(9) function to insert a Tab character into the menu item
name, so that the remaining text is shifted to the right.
Include "MENU.DEF"
If you want to prevent the user from having access to MapInfo Pro's shortcut menus, use a Create
Menu statement to re-create the appropriate menu, and define the menu as just a separator control
code: "(-". The following example uses this technique to disable the Map window's shortcut menu.
See Also:
Alter Menu Item statement, Create Menu Bar statement
Syntax 1
Note: In MapInfo Pro 64-bit, this command creates a new menu group on the LEGACY tab and
each menu is created as a dropdown. Also, if a menu with same name already exists in the
menu group, this command would replace it with the new one.
Syntax 2
Note: In MapInfo Pro 64-bit, Syntax 2 above would remove the whole menu group.
menu_name is the name of a standard MapInfo Pro menu, or the name of a custom menu created
through a Create Menu statement.
menu_number is the number associated with a standard MapInfo Pro menu (for example, 1 for the
File menu).
Description
A Create Menu Bar statement tells MapInfo Pro which menus should appear on the menu bar, and
in what order. If the statement omits one or more of the standard menu names, the resultant menu
may be shorter than the standard MapInfo Pro menu. Conversely, if the statement includes the
names of one or more custom menus (which were created through the Create Menu statement),
the Create Menu Bar statement can create a menu bar that is longer than the standard MapInfo
Pro menu.
Any menu can be identified by its name (for example, "File"), regardless of whether it is a standard
menu or a custom menu. Each of MapInfo Pro's standard menus can also be referred to by its menu
ID; for example, the File menu has an ID of 1.
See Alter Menu Item statement for a listing of the names and ID numbers of MapInfo Pro's menus.
After the menu bar has been customized, the following statement:
restores the standard MapInfo Pro menu bar. Note that the Create Menu Bar As Default statement
removes any custom menu items that may have been added by other MapBasic applications that
may be running at the same time. For the sake of not accidentally disabling other MapBasic
applications, you should exercise caution when using the Create Menu Bar As Default statement.
Examples
The following example shortens the menu bar so that it includes only the File, Edit, Query, and
window-specific (for example, Map, Browse, etc.) menus.
Ordinarily, the MapInfo Pro menu bar only displays a Map menu when a Map window is the active
window. Similarly, MapInfo Pro only displays a Browse menu when a Browse window is the active
window. The following example redefines the menu bar so that it always includes both the Map and
Browse menus, even when no windows are on the screen. However, all items on the Map menu
will be disabled (grayed out) whenever the current window is not a Map window, and all items on
the Browse menu will be disabled whenever the current window is not a Browse window.
The following example creates a custom menu, called DataEntry, and then redefines the menu bar
so that it includes only the File, Edit, and DataEntry menus.
See Also:
Alter Menu Bar statement, Create Menu statement, Menu Bar statement
Syntax
Create Multipoint
[ Into { Window window_id | Variable var_name } ]
[ num_points ]
( x1, y1 ) ( x2, y2 ) [ ... ]
[ Symbol... ]
Currently MapInfo Pro uses the following four different syntaxes to define a symbol used for points:
shape is an integer, 31 or larger, specifying which character to use from MapInfo Pro's standard
symbol set. MapInfo 3.0 symbols refers to the symbol set that was originally published with MapInfo
for Windows 3.0 and has been maintained in subsequent versions of MapInfo Pro. To create an
invisible symbol, use 31. The standard set of symbols includes symbols 31 through 67, but the user
can customize the symbol set by using the Symbol application.
color is an integer RGB color value; see RGB() function.
size is an integer point size, from 1 to 48.
shape is an integer, 31 or larger, specifying which character to use from a TrueType font. To create
an invisible symbol, use 31.
color is an integer RGB color value; see RGB() function.
size is an integer point size, from 1 to 48.
fontname is a string representing a TrueType font name (for example, "Wingdings").
fontstyle is an integer code controlling attributes such as bold.
rotation is a floating-point number representing a rotation angle, in degrees.
filename is a string up to 31 characters long, representing the name of a bitmap file. The file must
be in the CUSTSYMB directory (unless a Reload Symbols statement has been used to specify a
different directory).
color is an integer RGB color value; see RGB() function.
size is an integer point size, from 1 to 48.
customstyle is an integer code controlling color and background attributes. See table below.
Syntax 5
Symbol symbol_expr
symbol_expr is a Symbol expression, which can either be the name of a Symbol variable, or a
function call that returns a Symbol value, for example, the MakeSymbol() function.
Example
See Also:
Objects Combine statement, Set Combine Version statement
Syntax
fromtable is the name of an open table, containing one or more graphic objects.
intotable is the name of an open table where the new object(s) will be stored.
varname is the name of an Object variable where a new object will be stored.
column is the name of a column in the table.
expression is an expression used to populate column.
Description
The Create Object statement creates one or more new region objects, by performing a geographic
operation (Buffer, Merge, Intersect, Union, ConvexHull, Voronoi, or Isogram) on one or more existing
objects.
The Into clause specifies where results are stored. To store the results in a table, specify Into Table.
To store the results in an Object variable, specify Into Variable. If you omit the Into clause, results
are stored in the source table.
Note: If you specify a Group By clause to perform data aggregation, you must store the results in
a table rather than a variable.
The keyword which follows the As keyword dictates what type of objects are created. Buffer and
Isogram are discussed in sections: Create Object As Buffer and Create Object As Isogram.
Union
Specify Union to perform a combine operation, which eliminates any areas of overlap. If you perform
the union operation on two overlapping regions (each of which contains one polygon), the end result
may be a region object that contains one polygon.
The union and merge operations are similar, but they behave very differently in cases where objects
are completely contained within other objects. In this case, the merge operation removes the area
of the smaller object from the larger object, leaving a hole where the smaller object was. The union
operation does not remove the area of the smaller object.
Create Objects As Union is similar to the Objects Combine statement. The Objects Combine
statement deletes the input and inserts a new combined object. Create Objects As Union only
inserts the new combined object, it does not delete the input objects. Combining using a Target and
potentially different tables is only available with the Objects Combine statement. The Combine
Objects using Column functionality is only available using Create Objects As Union using the
Group By clause.
If a Create Object As Union statement does not include a Group By clause, MapInfo Pro creates
one combined object for all objects in the table. If the statement includes a Group By clause, it must
name a column in the table to allow MapInfo Pro to group the source objects according to the
contents of the column and produce a combined object for each group of objects.
If you specify a Group By clause, MapInfo Pro groups all records sharing the same value, and
performs an operation (for example, Merge) on the group.
If you specify a Data clause, MapInfo Pro performs data aggregation. For example, if you perform
merge or union operations, you may want to use the Data clause to assign data values based on
the Sum() or Avg() aggregate functions.
Intersect
Specify Intersect to create an object representing the intersection of other objects (for example, if
two regions overlap, the intersection is the area covered by both objects).
Merge
Specify Merge to create an object representing the combined area of the source objects. The Merge
operation produces a results object that contains all of the polygons that belonged to the original
objects. If the original objects overlap, the merge operation does not eliminate the overlap. Thus, if
you merge two overlapping regions (each of which contains one polygon), the end result may be a
region object that contains two overlapping polygons. In general, Union should be used instead.
Convex Hull
The ConvexHull operator creates a polygon representing a convex hull around a set of points. The
convex hull polygon can be thought of as an operator that places a rubber band around all of the
points. It consists of the minimal set of points such that all other points lie on or inside the polygon.
The polygon is convex―no interior angle can be greater than 180 degrees.
The points used to construct the convex hull are any nodes from Regions, Polylines, or Points in
the fromtable. If a Create Object As ConvexHull statement does not include a Group By clause,
MapInfo Pro creates one convex hull polygon. If the statement includes a Group By clause that
names a column in the table, MapInfo Pro groups the source objects according to the contents of
the column, then creates one convex hull polygon for each group of objects. If the statement includes
a Group By RowID clause, MapInfo Pro creates one convex hull polygon for each object in the
source table.
Voronoi
Specify Voronoi to create regions that represent the Voronoi solutions of the input points. The data
values from the original input points can be assigned to the resultant polygon for that point by
specifying data clauses.
Example
The following example merges region objects from the Parcels table, and stores the resultant regions
in the table Zones. Since the Create Object statement includes a Group By clause, MapBasic
groups the Parcel regions, then performs one merge operation for each group. Thus, the Zones
table ends up with one region object for each group of objects in the Parcels table. Each group
consists of all parcels having the same value in the zone_id column.
Following the Create Object statement, the parcelcount column in the Zones table indicates how
many parcels were merged to produce that zone. The zonevalue column in the Zones table indicates
the sum of the values from the parcels that comprised that zone.
The next example shows a multi-object convex hull using the Create Object As statement.
See Also:
OverlayNodes() function, Set Buffer Version statement, Set Combine Version statement
Purpose
Creates a polygon boundary around points, lines, or other boundaries. You can issue this statement
from the MapBasic window in MapInfo Pro.
Syntax
bufferwidth is a number indicating the displacement used in a Buffer operation; if this number is
negative, and if the source object is a closed object, the resulting buffer is smaller than the source
object. If the width is negative, and the object is a linear object (line, polyline, arc) or a point, then
the absolute value of width is used to produce a positive buffer.
unitname
smoothness is an integer from 2 to 100, indicating the number of segments per circle in a Buffer
operation.
Description
If the Create Object statement performs a Buffer operation, the statement can include Width and
Resolution clauses. The Width clause specifies the width of the buffer. The optional Units sub-clause
lets you specify a distance unit name (such as "km" for kilometers) to apply to the Width clause. If
the Width clause does not include the Units sub-clause, the buffer width is interpreted in MapBasic's
current distance unit. By default, MapBasic uses miles as the distance unit; to change this unit, use
the Set Distance Units statement.
Type is the method used to calculate the buffer width around the object. It can either be Spherical
or Cartesian. Note that if the coordinate system of the intotable is NonEarth, then the calculations
are performed using Cartesian methods regardless of the option chosen, and if the coordinate
system of the intotable is Latitude/Longitude, then calculations are performed using Spherical
methods regardless of the option chosen.
The optional Type sub-clause lets you specify the type of distance calculation used to create the
buffer. If the Spherical type is used, then the calculation is done by mapping the data into a
Latitude/Longitude On Earth projection and using widths measured using Spherical distance
calculations. If the Cartesian type is used, then the calculation is done by considering the data to
be projected to a flat surface and widths are measured using Cartesian distance calculations. If the
Width clause does not include the Type sub-clause, then the default distance calculation type
Spherical is used. If the data is in a Latitude/Longitude projection, then Spherical calculations are
used regardless of the Type setting. If the data is in a NonEarth projection, the Cartesian calculations
are used regardless of the Type setting.
The Resolution keyword lets you specify the number of segments comprising each circle of the
buffer region. By default, a buffer object has a smoothness value of twelve (12), meaning that there
are twelve segments in a simple ring-shaped buffer region. By specifying a larger smoothness value,
you can produce smoother buffer regions. Note, however, that the larger the smoothness value, the
longer the Create Object statement takes, and the more disk space the resultant object occupies.
The optional Concurrency clause lets you distribute the processing to multiple cores to improves
performance. When Concurrency is set to none and the machine has more than one core, then
the other cores are left unused. This clause lets you specify the level of concurrency needed to
perform this operation on the map. Concurrency can have one of the following values:
• All: Full concurrency. All processors on your system perform the operation. This is the default
setting MapInfo Pro installs with.
• Aggressive: Aggressive concurrency, 75% of the processors on your system perform the operation.
• Intermediate: Intermediate concurrency, 50% of the processors on your system perform the
operation.
• Moderate: Moderate concurrency, 25% of the processors on your system perform the operation.
• None: No concurrency. A single processor performs the operation. This option provides the least
amount of processing speed.
For example:
In addition to the five possible concurrency values, you can also specify the number of cores to use,
such as eight (8). If your computer has less than the specified number of cores, MapBasic defaults
to using all available cores on that machine. Specifying zero (0), a negative number, or invalid text
that is different from the five possible concurrency values causes an error.
The following commands display an error message:
Group by Rowid
Concurrency -5
Note: You can only use concurrency if the One buffer for each object option is selected in the
Buffer Objects dialog box. If this option is not selected and you specify the Concurrency
clause, then it is ignored and there is no error message.
If a Create Object As Buffer statement does not include a Group By clause, MapInfo Pro creates
one buffer region. If the statement includes a Group By clause which names a column in the table,
MapInfo Pro groups the source objects according to the contents of the column, then creates one
buffer region for each group of objects. If the statement includes a Group By RowID clause, MapInfo
Pro creates one buffer region for each object in the source table.
Example
The next example creates a region object, representing a quarter-mile buffer around whatever
objects are currently selected. The buffer object is stored in the Object variable, corridor. A subsequent
Update statement or Insert statement could then copy the object to a table.
See Also:
Set Buffer Version statement
Syntax
Description
If the Create Object statement performs an Isogram operation, you must pass a connection_handle
that corresponds to an open connection created with an Open Connection statement. You must
specify a Distance clause or a Time clause to create the size of the Isogram desired. The Distance
clause can contain one or more distance expressions with an optional brush and/or pen for each
one. If you do not specify a Brush clause or Pen clause the current brush and pen is used. No
matter how many Distance instances you specify a single Units string must be provided to indicate
the units in which the distances are expressed.
By specifying a Time clause, you can create regions based on time, with each one having an optional
Brush clause and/or Pen clause. If you do not specify a Brush clause or Pen clause the current
brush and pen is used. No matter how many Time instances you specify a single Units string must
be provided to indicate the units in which the times are expressed. The maximum amount of values
allowed is 50. Each value creates a separate band that can be either specific times or specific
distances. Larger values take substantially longer to create. Many items factor into the equation,
but in general, using the Set Connection Isogram statement with MajorRoadsOnly specified,
results in a much quicker response compared to using the entire road network. MapBasic only allows
distances of 35 miles with MajorRoadsOnly Off and 280 miles with MajorRoadsOnly On. similarly,
the maximum time is 0.5 hours with MajorRoadsOnly Off and 4 hours with MajorRoadsOnly On.
See Also:
Buffer() function, ConvexHull() function, Objects Combine statement, Objects Erase statement,
Objects Intersect statement, Open Connection statement
Syntax
Create Pline
[ Into { Window window_id | Variable var_name } ]
[ Multiple num_sections ]
num_points ( x1, y1 ) ( x2, y2 ) [ ... ]
[ Pen... ]
[ Smooth ] [ Priority n ] [ Name framename ]
Description
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.
If the statement includes the optional Into Variable clause, the object will be stored in the specified
object variable. If the Into clause specifies a Window identifier, the object will be stored in the
appropriate place in the window (for example, in the editable layer of a Map window). If you omit
the Into clause, MapInfo Pro attempts to store the object in the topmost window; if objects cannot
be stored in the topmost window; no object is created.
The x and y parameters use whatever coordinate system MapBasic is currently using
(Longitude/Latitude by default). Objects created on a Layout window, however, are specified in
paper units. For details about paper units, see Set Paper Units statement. By default, MapBasic
uses inches as the paper unit. To use a different paper unit, use the Set Layout statement. If you
need to create objects on a Layout window, you must first issue a Set CoordSys Layout statement.
The optional Pen clause specifies a line style. If no Pen clause is specified, the Create Pline
statement will use the current line style (the style which appears in the MapInfo Pro Line Style
dialog box). Smooth will smooth the line so that it appears to be one continuous line with curves
instead of angles.
When creating a clone statement or saving a workspace, MapInfo Pro normalizes the priority of
frames to a unique set of values beginning with one (1). Use the Priority clause to assign the Z-Order
of the newly created object frame on the Layout window.
The Name clause assigns a name to a frame in the Layout window. If a name is assigned, it is
written to the workspace (WOR) file and the workspace version updates to 1500.
A single-section polyline can contain up to 134,217,724 nodes. The maximum number of segments
in a multi-segment polyline is 24,403,223.
See Also:
Alter Object statement, Insert statement, Pen clause, Set CoordSys statement, Update
statement
CreatePoint() function
Purpose
Returns an Object value representing a point. You can call this function from the MapBasic window
in MapInfo Pro.
Syntax
CreatePoint( x, y )
Return Value
Object
Description
The CreatePoint() function returns an Object value representing a point.
The x and y parameters should 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. Note that MapBasic's
coordinate system is independent of the coordinate system of any Map window.
The point object will use whatever Symbol style is currently selected. To create a point object with
a specific Symbol style, you could issue the Set Style statement before calling CreatePoint().
Alternately, instead of calling CreatePoint(), you could issue a Create Point statement, which has
an optional Symbol clause.
The point object created through the CreatePoint() 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).
Note: If you need to create objects on a Layout window, you must first issue a Set CoordSys
statement.
Examples
The following example uses the Insert statement to insert a new row into the table Sites. The
CreatePoint() function is used within the body of the Insert statement to specify the graphic object
that will be attached to the new row.
The following example assumes that the table Sites has Xcoord and Ycoord columns, which indicate
the longitude and latitude positions of the data. The Update statement uses the CreatePoint()
function to build a point object for each row in the table. Following the Update operation, each row
in the Sites table will have a point object attached. Each point object will be located at the position
indicated by the Xcoord, Ycoord columns.
The above example assumes that the Xcoord, Ycoord columns contain actual longitude and latitude
degree values.
See Also:
Create Point statement, Insert statement, Update statement
Syntax
Create Point
[ Into { Window window_id | Variable var_name } ]
( x, y )
[ Symbol... ] [ Priority n ] [ Name framename ]
Description
The Create Point statement creates a point object.
If the statement includes the optional Into Variable clause, the object will be stored in the specified
object variable. If the Into clause specifies a window identifier, the object will be stored in the
appropriate place in the window (for example, in the editable layer of a Map window). If the Into
clause is not provided, MapBasic will attempt to store the object in the topmost window; if objects
may not be stored in the topmost window (for example, if the topmost window is a grapher) no object
will be created.
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. Note that MapBasic's coordinate system
is independent of the coordinate system of any Map window. Objects created on a Layout window,
however, are specified in paper units: each x-coordinate represents a distance from the left edge
of the page, while each y-coordinate represents the distance from the top edge of the page. For
details about paper units, see Set Paper Units statement. By default, MapBasic uses inches as
the default paper unit. To use a different paper unit, use the Set Paper Units statement.
Note: If you need to create objects on a Layout window, you must first issue a Set CoordSys
Layout statement.
The optional Symbol clause specifies a symbol style; see Symbol clause for more details. If no
Symbol clause is specified, the Create Point statement uses the current symbol style (the style
which appears in the Symbol Style dialog box).
When creating a clone statement or saving a workspace, MapInfo Pro normalizes the priority of
frames to a unique set of values beginning with one (1). Use the Priority clause to assign the Z-Order
of the newly created object frame on the Layout window.
The Name clause assigns a name to a frame in the Layout window. If a name is assigned, it is
written to the workspace (WOR) file and the workspace version updates to 1500.
See Also:
CreatePoint() function, Insert statement, Symbol clause, Update statement
Syntax
Create PrismMap
[ From Window window_ID | MapString mapper_creation_string ]
{ layer_id | layer_name }
With expr
[ Camera [Pitch angle | Roll angle | Yaw angle | Elevation angle] |
[ Position ( x, y, z ) | FocalPoint ( x, y, z ) ] |
[ Orientation(vu_1, vu_2, vu_3, vpn_1, vpn_2, vpn_3,
clip_near, clip_far) ]
]
[ Light Color lightcolor ]
[ Scale grid_scale ]
[ Background backgroundcolor ]
window_id is a window identifier a for a Map window which contains a region layer. An error message
is displayed if a layer with regions is not found.
mapper_creation_string specifies a command string that creates the mapper textured on the Prism
map.
layer_id is the layer identifier of a layer in the map (one or larger).
layer_name is the name of a layer in the map.
expr is an expression that is evaluated for each row in the table.
Camera specifies the camera position and orientation.
angle is an angle measurement in degrees. The horizontal angle in the dialog box ranges from
0-360 degrees and rotates the maps around the center point of the grid. The vertical angle in the
dialog box ranges from 0-90 and measures the rotation in elevation from the start point directly over
the map.
Pitch adjusts the camera's current rotation about the x-axis centered at the camera's origin.
Roll adjusts the camera's current rotation about the z-axis centered at the camera's origin.
Yaw adjusts the camera's current rotation about the y-axis centered at the camera's origin.
Elevation adjusts the current camera's rotation about the x-axis centered at the camera's focal
point.
Position indicates the camera and/or light position.
FocalPoint indicates the camera and/or light focal point.
Orientation specifies the camera's ViewUp (vu_1, vu_2, vu_3), ViewPlane Normal (vpn_1, vpn_2,
vpn_3) and Clipping Range (clip_near and clip_far), used specifically for persistence of view).
grid_scale is the amount to scale the grid in the z direction. A value >1 will exaggerate the topology
in the z direction, a value <1 will scale down the topological features in the z direction.
backgroundcolor is a color to be used to set the background and is specified using the RGB()
function.
Description
The Create PrismMap statement creates a Prism Map window. The Prism Map is a way to associate
multiple variables for a single object in one visual. For example, the color associated with a region
may be the result of thematic shading while the height the object is extruded through may represent
a different value. The Create PrismMap statement corresponds to MapInfo Pro's Prism Map
command.
Between sessions, MapInfo Pro preserves Prism Maps settings by storing a Create PrismMap
statement in the workspace file. Thus, to see an example of the Create PrismMap statement, you
could create a map, choose the Add Theme command on the MAP tab, save the workspace (for
example, PRISM.WOR), and examine the workspace in a MapBasic text edit window. You could
then copy the Create PrismMap statement in your MapBasic program. Similarly, you can see
examples of the Create PrismMap statement by opening the MapBasic window before you choose
Add Theme.
Each Create PrismMap statement must specify an expr expression clause. MapInfo Pro evaluates
this expression for each object in the layer; following the Create PrismMap statement, MapInfo Pro
chooses each object's display style based on that record's expr value. The expression typically
includes the names of one or more columns from the table being shaded.
The optional window_id clause identifies which map layer to use in the prism map; if no window_id
is provided, MapBasic uses the topmost Map window. The Create PrismMap statement must specify
which layer to use, even if the Map window has only one layer. The layer may be identified by
number (layer_id), where the topmost map layer has a layer_id value of one, the next layer has a
layer_id value of two, etc. Alternately, the Create PrismMap statement can identify the map layer
by name (for example, "world").
Example
RGB(192,192,192)
See Also:
Set PrismMap statement, PrismMapInfo() function
Syntax
Create Query
From Window window_id
Into query_name
Error Conditions
ERR_TABLE_ALREADY_OPEN error is generated if there is already a table open with the name
query_name and the table is not a query table.
Description
After you have applied sort and/or filter conditions to a Browser window, you might want to perform
other operations on the results of the filter. Use the Create Query statement to generate a query
table that represents the current contents of the Browser. The resulting query represents the set of
rows that satisfies the filter conditions. You can then use the query in other MapBasic statements,
such as the Update statement, Commit Table statement, and Map statement.
Example
See Also:
Set Browse statement, Select statement
Syntax
Create Ranges
From table
With expr
[ Use { "Equal Ranges" | "Equal Count" | "Natural Break" | "StdDev" }
]
[ Quantile Using q_expr ]
[ Number num_ranges ]
[ Round rounding_factor ]
Into Variable array_variable
Description
The Create Ranges statement calculates a set of range values which can then be used in a Shade
statement (which creates a thematic map layer). For an introduction to thematic maps, see the
MapInfo Pro documentation.
The optional Use clause specifies how to break the data into ranges. If you specify "Equal Ranges"
each range covers an equal portion of the spectrum of values (for example, 0-25, 25-50, 50-75,
75-100). If you specify "Equal Count" the ranges are constructed so that there are approximately
the same number of rows in each range. If you specify "Natural Break" the ranges are dictated by
natural breaks in the set of data values. If you specify "StdDev" the middle range breaks at the mean
of your data values, and the ranges above and below the middle range are one standard deviation
above or below the mean. MapInfo Pro uses the population standard deviation (N - 1).
The Into Variable clause specifies the name of the float array variable that will hold the range
information. You do not need to pre-size the array; MapInfo Pro automatically enlarges the array,
if necessary, to make room for the range information. The final size of the array is twice the number
of ranges, because MapInfo Pro calculates a high value and a low value for each range.
After calling Create Ranges, call the Shade statement to create the thematic map, and use the
Shade statement's optional From Variable clause to read the array of ranges. The Shade statement
usually specifies the same table name and column expression as the Create Ranges statement.
Quantiled Ranges
If the optional Quantile Using clause is present, the Use clause is ignored and range limits are
defined according to the q_expr.
Quantiled ranges are best illustrated by example. The following statement creates ranges of buying
power index (BPI) values, and uses state population statistics to perform quantiling to set the range
limits.
Because of the Number 5 clause, this example creates a set of five ranges.
Because of the With BPI_1990 clause, states with the highest BPI values will be placed in the
highest range (the deepest color), and states with the lowest BPI values will be placed in the lowest
range (the palest color).
Because of the Quantile Using Pop_1990 clause, the range limits for the intermediate ranges
are calculated by quantiling, using a method that takes state population (Pop_1990) into account.
Since the Quantile Using clause specifies the Pop_1990 column, MapInfo Pro calculates the total
1990 population for the table (which, for the United States, is roughly 250 million). MapInfo Pro
divides that total by the number of ranges (in this case, five ranges), producing a result of fifty million.
MapInfo Pro then tries to define the ranges in such a way that the total population for each range
approximates, but does not exceed, fifty million.
MapInfo Pro retrieves rows from the States table in order of BPI values, starting with the states
having low BPI values. MapInfo Pro assigns rows to the first range until adding another row would
cause the cumulative population to match or exceed fifty million. At that time, MapInfo Pro considers
the first range "full" and then assigns rows to the second range. MapInfo Pro places rows in the
second range until adding another row would cause the cumulative total to match or exceed 100
million; at that point, the second range is full, etc.
Example
Include "mapbasic.def"
Create Styles
From Brush(2, CYAN, 0) 'style for LOW range
To Brush (2, BLUE, 0) 'style for HIGH range
Vary Color By "RGB"
Number 5
Into Variable brush_styles
' Store a column name in the Alias variable:
col_name = "Pop_1990"
Shade states
With col_name
Ranges
From Variable range_limits
Style Variable brush_styles
See Also:
Create Styles statement, Set Shade statement, Shade statement
Syntax
Create Rect
[ Into { Window window_id | Variable var_name } ]
( x1, y1 ) ( x2, y2 )
[ Pen ... ]
[ Brush ... ] [ Priority n ] [ Name framename ]
Description
If the Create Rect statement includes the optional Into Variable clause, the object will be stored in
the specified object variable. If the Into clause specifies a Window identifier, the object will be stored
in the appropriate place in the window (for example, in the editable layer of a Map window). If the
Into clause is not provided, MapBasic will attempt to store the object in the topmost window; if
objects may not be stored in the topmost window (for example, if the topmost window is a grapher)
no object will be created.
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. Note that MapBasic's coordinate
system is independent of the coordinate system of any Map window. Objects created on a Layout
window, however, are specified in paper units: each x-coordinate represents a distance from the
left edge of the page, while each y-coordinate represents the distance from the top edge of the
page. For details about paper units, see Set Paper Units statement. By default, MapBasic uses
inches as the default paper unit. To use a different paper unit, call the Set Paper Units statement.
Note: If you need to create objects on a Layout window, you must first issue a Set CoordSys
Layout statement.
The optional Pen clause specifies a line style; see Pen clause for more details. If no Pen clause
is specified, the Create Rect statement uses the current line style (the style which appears in the
Line Style dialog box). Similarly, the optional Brush clause specifies a fill style; see Brush clause
for more details.
When creating a clone statement or saving a workspace, MapInfo Pro normalizes the priority of
frames to a unique set of values beginning with one (1). Use the Priority clause to assign the Z-Order
of the newly created object frame on the Layout window.
The Name clause assigns a name to a frame in the Layout window. If a name is assigned, it is
written to the workspace (WOR) file and the workspace version updates to 1500.
See Also:
Brush clause, Create RoundRect statement, Insert statement, Pen clause, Update statement
Syntax
source_table is the name of the table containing objects to be grouped into districts.
district_column is the name of a column; the initial set of districts is built from the original contents
of this column, and as objects are assigned to different districts, MapInfo Pro stores the object's
new district name in this column.
layer_number is the number of a layer in the current Map window (for example, 1 for the top layer);
to determine the number of layers in a Map window, call the MapperInfo() function.
Count keyword specifies that the Districts Browser will show a count of the objects belonging to
each district.
Brush keyword specifies that the Districts Browser will show each district's fill style.
Symbol keyword specifies that the Districts Browser will show each district's symbol style.
Pen keyword specifies that the Districts Browser will show each district's line style.
expr is a numeric column expression.
Percentage From clause specifies in-row calculation.
Order clause specifies the order of rows in the Districts Browser (alphabetical, unsorted, or based
on most-recently-used); default is MRU.
Description
The Create Redistricter statement begins a redistricting session. This statement corresponds to
choosing MapInfo Pro's Redistricter command on the HOME tab. For an introduction to redistricting,
see the MapInfo Pro documentation.
To control the set of districts, use the Set Redistricter statement. To end the redistricting session,
use the Close Window statement to close the Districts Browser window.
If you include the Brush keyword, the Districts Browser includes a sample of each district's fill style.
Note that this is not a complete Brush clause; the keyword Brush appears by itself. Similarly, the
Symbol and Pen keywords are individual keywords, not a complete Symbol clause or Pen clause.
If the Districts Browser includes brush, symbol, and/or pen styles, the user can change a district's
style by clicking on the style sample that appears in the Districts Browser.
The Percentage From clause allows you to specify the in-row mode of percentage calculation. If
the Percentage From clause is not specified, the in-column method of calculation is used.
See Also:
Set Redistricter statement
Syntax
Create Region
[ Into { Window window_id | Variable var_name } ]
num_polygons
Description
The Create Region statement creates a region object.
The num_polygons parameter specifies the number of polygons which comprise the region object.
If you specify a num_polygons parameter with a value of zero, the object will be created as an empty
region (a region with no polygons). You can then use t