MapBasic

Version 8.5

REFERENCE GUIDE

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 MapInfo Corporation, One Global View, Troy, New York 12180-8399. © 2006 MapInfo Corporation. All rights reserved. MapInfo, the MapInfo logo and MapBasic are trademarks of MapInfo Corporation and/or its affiliates. MapInfo Corporate Headquarters: Voice: (518) 285-6000 Fax: (518) 285-6070 Sales Info Hotline: (800) 327-8627 Government Sales Hotline: (800) 619-2333 Technical Support Hotline: (518) 285-7283 Technical Support Fax: (518) 285-6080 Contact information for all MapInfo offices is located at: http://www.mapinfo.com/contactus. Adobe Acrobat® is a registered trademark of Adobe Systems Incorporated in the United States. 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. May 2006

Table of Contents
Chapter 1: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Language Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 MapBasic Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Looping and Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Output and Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Procedures (Main and Subs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Data-Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Date and Time Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Math Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Working With Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Creating and Modifying Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Querying Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Working With Remote Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Working With Files (Other Than Tables) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 File Input/Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 File and Directory Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Working With Maps and Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Creating Map Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Modifying Map Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Querying Map Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 Working With Object Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 Working With Map Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Creating the User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 ButtonPads (ToolBars). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 System Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30

Table of Contents

Communicating With Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 DDE (Dynamic Data Exchange; Windows Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Integrated Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Special Statements and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Chapter 2: New and Enhanced MapBasic Statements and Functions . . . . . . . . 32
New MapBasic Functions and Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Close Connection statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 EPSGToCoordSysString$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Geocode statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 GeocodeInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 IsogramInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 ObjectNodeHasM( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 ObjectNodeHasZ( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Open Connection statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Set Connection Geocode statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Set Connection Isogram statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Enhanced MapBasic Functions and Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Create Object statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Create Redistricter statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 LocateFile$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 MapperInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 ObjectGeography( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Open Table statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Open Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 SessionInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Set Map statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Set Redistricter statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Set Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Shade statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 TableInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 UnitAbbr$( ) and UnitName$( ) functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 WindowInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Chapter 3: A – Z Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Abs( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Acos( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Add Cartographic Frame statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Add Column statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Add Map statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Alter Button statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Alter ButtonPad statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

4
MB_Ref.pdf © 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Table of Contents

Alter Cartographic Frame statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 Alter Control statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 Alter MapInfoDialog statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 Alter Menu statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85 Alter Menu Bar statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Alter Menu Item statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90 Alter Object statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92 Alter Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 ApplicationDirectory$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 Area( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 AreaOverlap( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101 Asc( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Asin( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Ask( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 Atn( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105 AutoLabel statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106 Beep statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 Browse statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 Brush clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Buffer( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111 ButtonPadInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112 Call statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 CartesianArea( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115 CartesianBuffer( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 CartesianConnectObjects( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117 CartesianDistance( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117 CartesianObjectDistance( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 CartesianObjectLen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 CartesianOffset( ) Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 CartesianOffsetXY( ) Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121 CartesianPerimeter( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Centroid( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123 CentroidX( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 CentroidY( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 CharSet clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 ChooseProjection$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128 Chr$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Close All statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Close Connection statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Close File statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 Close Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

5
MB_Ref.pdf

Table of Contents

Close Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 ColumnInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Combine( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 CommandInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Commit Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 ConnectObjects( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Continue statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Control Button / OKButton / CancelButton clause . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 Control CheckBox clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Control DocumentWindow clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Control EditText clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Control GroupBox clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Control ListBox / MultiListBox clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Control PenPicker/BrushPicker/SymbolPicker/FontPicker clause . . . . . . . . . . . . . . 155 Control PopupMenu clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Control RadioGroup clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Control StaticText clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 ConvertToPline( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 ConvertToRegion( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 ConvexHull( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 CoordSys clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Cos( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Create Arc statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Create ButtonPad statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Create ButtonPads As Default statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 Create Cartographic Legend statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 CreateCircle( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Create Collection statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Create Cutter statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Create Ellipse statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Create Frame statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Create Grid statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Create Index statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Create Legend statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 CreateLine( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Create Line statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Create Map statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Create Map3D statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Create Menu statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Create Menu Bar statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Create MultiPoint statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

6
MB_Ref.pdf © 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Table of Contents

Create Object statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .199 Create Pline statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204 CreatePoint( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 Create Point statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 Create PrismMap statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 Create Ranges statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209 Create Rect statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212 Create Redistricter statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213 Create Region statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214 Create Report From Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 Create RoundRect statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 Create Styles statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217 Create Table statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 CreateText( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221 Create Text statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222 CurDate( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223 CurrentBorderPen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224 CurrentBrush( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225 CurrentFont( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225 CurrentLinePen( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226 CurrentPen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 CurrentSymbol( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228 DateWindow( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 Day( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 DDEExecute statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .230 DDEInitiate( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .231 DDEPoke statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 DDERequest$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235 DDETerminate statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238 DDETerminateAll statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238 Declare Function statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239 Declare Sub statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241 Define statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243 DeformatNumber$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244 Delete statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 Dialog statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246 Dialog Preserve statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252 Dialog Remove statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253 Dim statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .254 Distance( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 Do Case…End Case statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

7
MB_Ref.pdf

Table of Contents

Do…Loop statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Drop Index statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Drop Map statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Drop Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 End MapInfo statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 End Program statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 EndHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 EOF( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 EOT( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 EPSGToCoordSysString$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Erase( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 Err( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Error statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 Error$( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 Exit Do statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Exit For statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Exit Function statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Exit Sub statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Exp( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Export statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 ExtractNodes( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 Farthest statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 Fetch statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 FileAttr( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 FileExists( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 FileOpenDlg( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 FileSaveAsDlg( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Find statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Find Using statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 Fix( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Font clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 For…Next statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 ForegroundTaskSwitchHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Format$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 FormatDate$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 FormatNumber$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 FrontWindow( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 Function… End Function statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 Geocode statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 GeocodeInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 Get statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

8
MB_Ref.pdf © 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Table of Contents

GetFolderPath$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .316 GetMetadata$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317 GetSeamlessSheet( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318 Global statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319 Goto statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320 Graph statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320 HomeDirectory$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 If…Then statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 Import statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325 Include statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .330 Input # statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .331 Insert statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332 InStr( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 Int( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334 IntersectNodes( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335 IsogramInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 IsPenWidthPixels( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337 Kill statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338 LabelFindByID( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339 LabelFindFirst( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .340 LabelFindNext( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341 Labelinfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341 LayerInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .344 Layout statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348 LCase$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349 Left$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .350 LegendFrameInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351 LegendInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352 LegendStyleInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .353 Len( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .354 Like( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355 Line Input statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356 LocateFile$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .357 LOF( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .358 Log( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .359 LTrim$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .360 Main procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .360 MakeBrush( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362 MakeCustomSymbol( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .363 MakeFont( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .364 MakeFontSymbol( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

9
MB_Ref.pdf

Table of Contents

MakePen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 MakeSymbol( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Map statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Map3DInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 MapperInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 Maximum( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 MBR( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 Menu Bar statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378 MenuItemInfoByHandler( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 MenuItemInfoByID( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 Metadata statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 MGRSToPoint( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 Mid$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 MidByte$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386 Minimum( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 Month( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 Nearest statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 Note statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 NumAllWindows( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 NumberToDate( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 NumCols( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 NumTables( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 NumWindows( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 ObjectDistance( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 ObjectGeography( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 ObjectInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 ObjectLen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 ObjectNodeHasM( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 ObjectNodeHasZ( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 ObjectNodeM( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 ObjectNodeX( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 ObjectNodeY( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 ObjectNodeZ( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 Objects Check statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 Objects Clean statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 Objects Combine statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 Objects Disaggregate statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 Objects Enclose statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 Objects Erase statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 Objects Intersect statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 Objects Move statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422

10
MB_Ref.pdf © 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Table of Contents

Objects Offset statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423 Objects Overlay statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .424 Objects Pline statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425 Objects Snap statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426 Objects Split statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428 Offset( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .430 OffsetXY( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .431 OnError statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .432 Open Connection statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .434 Open File statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435 Open Report statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .437 Open Table statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .438 Open Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .440 Overlap( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .441 OverlayNodes( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442 Pack Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443 PathToDirectory$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .444 PathToFileName$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .444 PathToTableName$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .445 Pen clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .446 PenWidthToPoints( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .449 Perimeter( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .450 PointsToPenWidth( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .451 PointToMGRS$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .452 Print statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .453 Print # statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .454 PrintWin statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .455 PrismMapInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .456 ProgramDirectory$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 ProgressBar statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 Proper$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462 ProportionOverlap( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463 Put statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463 Randomize statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .464 ReadControlValue( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .465 ReDim statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .467 Register Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .469 Relief Shade statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .474 Reload Symbols statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .475 RemoteMapGenHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476 RemoteMsgHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

11
MB_Ref.pdf

Table of Contents

RemoteQueryHandler( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477 Remove Cartographic Frame statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 Remove Map statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 Rename File statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 Rename Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 Reproject statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 Resume statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 RGB( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 Right$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 Rnd( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 Rollback statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 Rotate( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 RotateAtPoint( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 Round( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488 RTrim$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 Run Application statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 Run Command statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 Run Menu Command statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492 Run Program statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494 Save File statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495 Save MWS statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495 Save Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 Save Workspace statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 SearchInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 SearchPoint( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 SearchRect( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 Seek( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504 Seek statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 SelChangedHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 Select statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 SelectionInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515 Server Begin Transaction statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517 Server Bind Column statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517 Server Close statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Server_ColumnInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Server Commit statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 Server_Connect( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 Server_ConnectInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 Server Create Map statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530 Server Create Style statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 Server Create Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533

12
MB_Ref.pdf © 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Table of Contents

Server Create Workspace statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .535 Server Disconnect statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .536 Server_DriverInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .536 Server_EOT( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .537 Server_Execute( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .538 Server Fetch statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .539 Server_GetODBCHConn( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .541 Server_GetODBCHStmt( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .542 Server Link Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .543 Server_NumCols( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .545 Server_NumDrivers( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .546 Server Refresh statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .547 Server Remove Workspace statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .548 Server Rollback statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .548 Server Set Map statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549 Server Versioning statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .550 Server Workspace Merge statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .551 Server Workspace Refresh statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .553 SessionInfo ( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .555 Set Application Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .556 Set Area Units statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .557 Set Browse statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .558 Set Cartographic Legend statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .559 Set Command Info statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .560 Set Connection Geocode statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .561 Set Connection Isogram statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .564 Set CoordSys statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .566 Set Date Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .567 Set Digitizer statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .568 Set Distance Units statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .570 Set Drag Threshold statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .571 Set Event Processing statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .571 Set File Timeout statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .572 Set Format statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .573 Set Graph statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .574 Set Handler statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .579 Set Layout statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .580 Set Legend statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .582 Set Map statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .585 Set Map3D statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .597 Set Next Document statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .599

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

13
MB_Ref.pdf

Table of Contents

Set Paper Units statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 Set PrismMap statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 Set ProgressBars statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603 Set Redistricter statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604 Set Resolution statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605 Set Shade statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606 Set Style statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607 Set Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608 Set Target statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 Set Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 Sgn( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 Shade statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621 Sin( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630 Space$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 SphericalArea( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 SphericalConnectObjects( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632 SphericalDistance( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 SphericalObjectDistance( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634 SphericalObjectLen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635 SphericalOffset( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 SphericalOffsetXY( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 SphericalPerimeter( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638 Sqr( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 StatusBar statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640 Stop statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641 Str$( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642 String$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643 StringCompare( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644 StringCompareIntl( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 StringToDate( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 StyleAttr( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 Sub…End Sub statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649 Symbol clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651 SystemInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 TableInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656 Tan( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659 TempFileName$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660 Terminate Application statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 TextSize( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 Time( ) Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662 Timer( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662

14
MB_Ref.pdf © 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Table of Contents

ToolHandler procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .663 TriggerControl( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .665 TrueFileName$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .666 Type statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .667 UBound( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .668 UCase$( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .669 UnDim statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .669 UnitAbbr$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .670 UnitName$( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .671 Unlink statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .672 Update statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .672 Update Window statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .673 Val( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .674 Weekday( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .675 WFS Refresh Table statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .676 While…Wend statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .676 WinChangedHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .677 WinClosedHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .678 WindowID( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .679 WindowInfo( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .680 WinFocusChangedHandler procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .686 Write # statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .688 Year( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .688

Appendix 4: HTTP and FTP Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
MICloseContent( ) procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .691 MICloseFtpConnection( ) procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .691 MICloseFtpFileFind( ) procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .691 MICloseHttpConnection( ) procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .692 MICloseHttpFile( ) procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .692 MICloseSession( ) procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .693 MICreateSession( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .693 MICreateSessionFull( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .694 MIErrorDlg( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .695 MIFindFtpFile( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .697 MIFindNextFtpFile( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .697 MIGetContent( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .698 MIGetContentBuffer( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .698 MIGetContentLen( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .699 MIGetContentString( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .700 MIGetContentToFile( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .700 MIGetContentType( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .701
Reference Guide © 2006 MapInfo Corporation. All rights reserved.

15
MB_Ref.pdf

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727 MIXmlGetChildList( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 MIGetFtpConnection( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701 MIGetErrorCode( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 MIIsFtpDots( ) function . . . 703 MIGetFileURL( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 . . 722 MIXmlDocumentGetRootNode( ) function . . . . . . . . . 715 MISaveContent( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 MIParseURL( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 MIXmlDocumentLoadXML( ) function . . . . . . . . . . . 717 MISetCurrentFtpDirectory( ) function . . . . . 707 MIGetHttpConnection( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 MIOpenRequestFull( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 MIGetFtpFileFind( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702 MIGetErrorMessage( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720 MIXmlAttributeListDestroy( ) procedure. . . . 721 MIXmlDocumentCreate( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716 MISendSimpleRequest( ) function. . . . . 712 MIPutFtpFile( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MapBasic 8. . . . . . . . . . .Table of Contents MIGetCurrentFtpDirectory( ) function . . . . . . . . . . . . 724 MIXmlDocumentLoadXMLString( ) function. . . 728 MIXmlGetNextNode( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 MIGetFtpFileName( ) procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 MISetSessionTimeout( ) function . 730 MIXmlNodeGetName( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . 730 MIXmlNodeGetFirstChild( ) function . . . . . . . . . . . . . . . . . . 726 MIXmlGetAttributeList( ) function . . . . . . . . . . . . . . . . . . . . . . . 727 MIXmlGetNextAttribute( ) function . . . . . . . . . . . . . . . . . . . . . 707 MIIsFtpDirectory( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 MIGetFtpFile( ) function . . 723 MIXmlDocumentLoad( ) function. . . 732 16 MB_Ref. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 MIXmlNodeGetParent( ) function. . . . . . . . . . . . . . . 716 MISendRequest( ) function. . . . . . . . . . . All rights reserved. . . . . . 722 MIXmlDocumentGetNamespaces( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 MIQueryInfo( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 Appendix 5: XML Library . . . . . . . . . . . . . . . . . . . . . . . 729 MIXmlNodeGetAttributeValue( ) function . . . 729 MIXmlNodeDestroy( ) procedure . . . . . . 725 MIXmlDocumentSetProperty( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721 MIXmlDocumentDestroy( ) procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 MIQueryInfoStatusCode( ) function. . . . . . . . . 709 MIOpenRequest( ) function . . . . . . .pdf © 2006 MapInfo Corporation. . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . .742 Automatic Type Conversions. . . . . . . . . . . . . . . . . . . . . .741 Geographical Operators . . . . . .735 MIXmlSelectSingleNode( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .740 Logical Operators . . . . . . . . . . . . . . . . . . .734 MIXmlSCGetLength( ) function . .Table of Contents MIXmlNodeGetText( ) function. . . . .732 MIXmlNodeGetValue( ) function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 Appendix 7: Summary of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .733 MIXmlSCDestroy( ) procedure . . . . . . . . . . . . . . . . . . . . . .742 Appendix 8: MapBasic Definitions File . . . . . . . . . . . . . . . . . .733 MIXmlNodeListDestroy( ) procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .735 MIXmlSelectNodes( ) function . . . . . . . . . . . . . . . . . 17 MB_Ref. . .734 MIXmlSCGetNamespace( ) function . . . . . . . . . . . . . . . . . . . . . . . . . . .736 Appendix 6: Character Code Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .pdf . 739 Comparison Operators . . . . . .741 Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . All rights reserved. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 Index 767 Reference Guide © 2006 MapInfo Corporation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 . . . . . . . . . . . . . . . . . . . . . . see the MapBasic User Guide. . . . . . . . . . . or to learn about using the MapBasic development environment.19 MapBasic Fundamentals . . . . . . . . . . . . To learn about the concepts behind MapBasic programming. . . . . . . . . . . . . .23 Working With Files (Other Than Tables) . . . . . . . . . . . .26 Creating the User Interface . . .28 Communicating With Other Applications . . . . . . . . . . . . In this chapter… Š Š Š Š Š Š Š Š Š Š Type Conventions . . . . . . . . . . . . . . . . . .21 Working With Tables .19 Language Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Working With Maps and Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Introduction 1 This manual describes every statement and function in the MapBasic Development Environment programming language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Special Statements and Functions . . . . . . . .

Call. When a syntax expression appears inside braces. Global ReDim. Area Meaning Bold words with the first letter capitalized are MapBasic keywords. Main. Italicized words represent parameters to MapBasic statements. handler. lower-. or mixed-case. however. you may enter keywords in upper-. Browse. table. Object Non-bold words with the first letter capitalized are usually special procedure names or variable types. when you write MapBasic programs. separated by the vertical bar character ( | ). Within this manual. you should choose either On or Off. Keywords or parameters which appear inside square brackets are optional. [ Interactive ] { On | Off } "Note "Hello.Chapter 1: Introduction Type Conventions This manual uses the following conventions to designate specific items in the text: Convention If. All rights reserved. the first letter of each keyword is capitalized. MapBasic Fundamentals Variables Declare local or global variables: Resize array variables: Declare custom data structure: Dim. Actual program samples are shown in Courier font. in bold. You must choose one of the options listed. Pen. you must supply an appropriate expression for each parameter. When you construct a MapBasic statement. Task descriptions appear on the left. window_id [ window_id ]. Map. the braces contain a list of keywords or parameters.world!" Language Overview The following pages provide an overview of the MapBasic language. corresponding statement names and function names appear on the right. UnDim Type Reference Guide © 2006 MapInfo Corporation. 19 . UBound( ). Function names are followed by parentheses ( ). For example. in the sample shown on the left ({ On | Off }).

Terminate Application. Do…Loop. While…Wend If…Then.MapBasic Fundamentals Looping and Branching Looping: For…Next. Do Case. End MapInfo Branching: Other flow control: Output and Printing Print a window's contents: Print text to message window: Set up a Layout window: Export a window to a file: Controlling the Printer: PrintWin Print Layout. Error$( ) Resume Error 20 © 2006 MapInfo Corporation. Create Frame. GoTo End Program. MapBasic 8.5 . Window Info( ) Procedures (Main and Subs) Define a procedure: Call a procedure: Exit a procedure: Main procedure: Declare Sub. Exit For. Set Window Save Window Set Window. Sub…End Sub Call Exit Sub Main Error Handling Set up an error handler: Return current error information: Return from error handler: Simulate an error: OnError Err( ). All rights reserved. Exit Do.

Format$( ) NumberToDate( ). Month( ). StringToDate( ) Set Date Window. StringToDate( ) Reference Guide © 2006 MapInfo Corporation. Function…End Function Exit Function Data-Conversion Functions Convert strings to codes: Convert codes to strings: Convert strings to numbers: Convert numbers to strings: Convert a number or a string to a date: Converting to a 2-Digit Year: Convert object types: Convert labels to text: Convert a point object to an MGRS coordinate: Convert a MGRS coordinate to a point object: Asc( ) Chr$( ) Val( ) Str$( ). Year( ) Timer( ) NumberToDate( ). DateWindow( ) ConvertToRegion( ). All rights reserved.Chapter 1: Introduction Functions Custom Functions Define a custom function: Exit a function: Declare Function. ConvertToPline( ) LabelInfo( ) PointToMGRS$( ) MGRSToPoint( ) Date and Time Functions Obtain the current date: Extract parts of a date: Read system timer: Convert a number or a string to a date: CurDate( ) Day( ). Weekday( ). 21 .

SphericalPerimeter( ). MapBasic 8. Proper$( ) InStr( ) Left$( ). String$( ) UnitAbbr$( ). Int( ). SphericalObjectLen( ) Randomize. RTrim$( ) Format$( ). LCase$( ). Mid$( ).Functions Math Functions Trigonometric functions: Geographic functions: Cos( ). Sqr( ) Random numbers: Sign-related functions: Truncating fractions: Other math functions: String Functions Upper / lower case: Find a sub-string: Extract part of a string: Trim blanks from a string: Format numbers as strings: UCase$( ). Sin( ). CartesianPerimeter( ). Log( ). DeformatNumber$( ) Len( ) Chr$( ). Sgn( ) Fix( ). ObjectLen( ). Minimum( ). Set Format. CartesianArea( ). Perimeter( ). Asc( ) Like( ). UnitName$( ) PointToMGRS$( ) MGRSToPoint( ) EPSGToCoordSysString$( ) Determine string length: Convert character codes: Compare strings: Repeat a string sequence: Return unit name: Convert a point object to an MGRS coordinate: Convert a MGRS coordinate to a point object: Convert an EPSG string to a CoordSys clause 22 © 2006 MapInfo Corporation. Round( ) Exp( ). Acos( ). Tan( ). Atn( ) Area( ). CartesianDistance( ). CartesianObjectLen( ). Right$( ). MidByte$( ) LTrim$( ). Distance( ). FormatNumber$( ).5 . SphericalDistance( ). SphericalArea( ). Rnd( ) Abs( ). Str$( ). Asin( ). StringCompareIntl( ) Space$( ). StringCompare( ). All rights reserved. Maximum( ).

All rights reserved. work with Selection: Find map objects by address: Find map objects at location: Obtain table information: Obtain column information: Fetch. Find Using. TableInfo( ) NumCols( ). Add Column. 23 . Drop Index.Chapter 1: Introduction Working With Tables Creating and Modifying Tables Open an existing table: Close one or more tables: Create a new. edit. ColumnInfo( ) Reference Guide © 2006 MapInfo Corporation. empty table: Turn a file into a table: Import/export tables/files: Modify a table's structure: Open Table Close Table. Drop Map Create Report From Table Open Report Insert. CommandInfo( ) SearchPoint( ). delete rows: Pack a table: Control table settings: Save recent edits: Discard recent edits: Rename a table: Delete a table: Querying Tables Position the row cursor: Select data. Create Map. Close All Create Table Register Table Import. Export Alter Table. SearchRect( ). Delete Pack Table Set Table Commit Table Rollback Rename Table Drop Table Create a Crystal Reports file: Load a Crystal Report: Add. EOT( ) Select. Update. SelectionInfo( ) Find. Create Index. SearchInfo( ) NumTables( ).

MapBasic 8.Working With Tables Query a table's metadata: Query seamless tables: GetMetadata$( ). Server_ConnectInfo( ) Server Begin Transaction Server Bind Column Server_ColumnInfo( ). Server_EOT( ) Server Commit Server Rollback Server Close Server Create Map Server Set Map Server Refresh Server Link Table Unlink Server Disconnect Server_DriverInfo( ). Server_NumCols( ) Server_Execute( ) Server Fetch. All rights reserved. Server_NumDrivers( ) Server_GetODBCHConn( ) Server_GetODBCHStmt( ) Server Create Style 24 © 2006 MapInfo Corporation. GetSeamlessSheet( ) Working With Remote Data Create a new table Communicate with data server: Begin work with remote server: Assign local storage: Obtain column information: Send an SQL statement: Position the row cursor: Save changes: Discard changes: Free remote resources: Make remote data mappable: Change object styles: Synchronize a linked table: Create a linked table: Unlink a linked table: Disconnect from server: Retrieve driver information: Get ODBC connection handle: Get ODBC statement handle: Set Object styles Server Create Table Server_Connect( ). Metadata TableInfo( ).5 .

Print #. ApplicationDirectory$( ) PathToTableName$( ). Input #. GetFolderPath$( ) Extract part of a filename: Return a full filename: Let user choose a file: Return temporary filename: Locate files: Reference Guide © 2006 MapInfo Corporation. Seek. LOF( ). Line Input Put. Write # EOF( ). FileSaveAsDlg( ) TempFileName$( ) LocateFile$( ). PathToFileName$( ) TrueFileName$( ) FileOpenDlg( ). HomeDirectory$( ). PathToDirectory$( ).Chapter 1: Introduction Working With Files (Other Than Tables) File Input/Output Open or create a file: Close a file: Delete a file: Rename a file: Copy a file: Read from a file: Write to a file: Determine file's status: Open File Close File Kill Rename File Save File Get. All rights reserved. 25 . FileExists( ) Register Table Set File Timeout Turn a file into a table: Retry on sharing error: File and Directory Names Return system directories: ProgramDirectory$( ). Seek( ). FileAttr( ).

Update Objects Enclose Creation functions: Advanced operations: Store object in table: Create regions: Modifying Map Objects Modify object attribute: Change object type: Offset objects: Set the editing target: Erase part of an object: Alter Object ConvertToRegion( ). CreateText( ) Create Object. Objects Split Objects Overlay. Create PLine.Working With Maps and Graphical Objects Working With Maps and Graphical Objects Creating Map Objects Creation statements: Create Arc. RotateAtPoint( ) Objects Pline. Create Object Rotate( ). Erase( ).5 . Objects Erase. Update Merge objects: Rotate objects: Split objects: Add nodes at intersections: Control object resolution: Store an object in a table: 26 © 2006 MapInfo Corporation. Create Object. Create Region. CreatePoint( ). Create Rect. Offset( ). Create Line. Create Point. ConvertToPLine( ) Objects Offset. Combine( ). Create RoundRect. Objects Intersect. AutoLabel. Buffer( ). Create Ellipse. OffsetXY( ). Create Frame. SphericalOffset( ). CartesianBuffer( ). Overlap( ) Objects Combine. CreateLine( ). Create Text. SphericalOffsetXY( ) Insert. Create Collection CreateCircle( ). CartesianOffsetXY( ). All rights reserved. MapBasic 8. ConvexHull( ). OverlayNodes( ) Set Resolution Insert. CartesianOffset( ). Objects Move Set Target CreateCutter. Create Multipoint.

ObjectLen( ). CurrentLinePen( ). Distance( ). CentroidY( ). CurrentBorderPen( ). AreaOverlap( ). ObjectNodeX( ). Objects Snap. Centroid( ). Perimeter( ). Set Style. Set Paper Units. distance. LabelFindFirst( ). RGB( ) ObjectInfo( ) Alter Object Return part of a style: Create style values: Query object's style: Modify object's style: Reference Guide © 2006 MapInfo Corporation. UnitAbbr$( ). MakeBrush( ). ObjectNodeZ( ).Chapter 1: Introduction Check Objects for bad data: Object processing: Objects Check Objects Disaggregate. IntersectNodes( ) SessionInfo( ) Return coordinate values: Return settings for coordinates. Overlap( ). ObjectNodeY( ). MakeCustomSymbol( ). MBR( ). Set Style. MakeFontSymbol( ). ExtractNodes( ). All rights reserved. CurrentSymbol( ). Labelinfo( ) Configure coordinate system: Return style settings: Query a map layer's labels: Working With Object Styles Return current styles: CurrentPen( ). MakeSymbol( ). CentroidX( ). ProportionOverlap( ) ObjectGeography( ). LabelFindNext( ). MakeFont( ). Objects Clean Querying Map Objects Return calculated values: Area( ). TextSize( ) StyleAttr( ) MakePen( ). UnitName$( ) Set CoordSys ObjectInfo( ) LabelFindByID( ). Set Distance Units. area and paper units: Configure units of measure: Set Area Units. CurrentFont( ). CurrentBrush( ). 27 .

Create PrismMap. Labelinfo( ) Add a layer to a map: Remove a map layer: Label objects in a layer: Query a map's settings: Change a map's settings: Create or modify thematic layers: Query a map layer's labels: Creating the User Interface ButtonPads (ToolBars) Create a new ButtonPad: Modify a ButtonPad: Modify a button: Query the status of a pad: Respond to button use: Restore standard pads: Create ButtonPad Alter ButtonPad Alter Button ButtonPadInfo( ) CommandInfo( ) Create ButtonPads As Default 28 © 2006 MapInfo Corporation. Symbol clause. Set Shade. Create Ranges. Create Grid. All rights reserved. LabelFindNext( ). LabelFindFirst( ). Font clause Working With Map Windows Open a map window: Create/edit 3DMaps: Map Create Map3D.Creating the User Interface Reload symbol styles: Style clauses: Reload Symbols Pen clause. MapBasic 8.5 . Set PrismMap. Map3DInfo( ). Relief Shade LabelFindByID( ). Set Map3D. PrismMapInfo( ) Add Map Remove Map AutoLabel MapperInfo( ). Brush clause. Create Styles. LayerInfo( ) Set Map Shade.

Set Window Map. Create Legend. Note. GetSeamlessSheet( ) Dialog Alter Control. Close Window. FileOpenDlg( ). Browse. Layout. Create Redistricter. ProgressBar. Dialog Preserve. Graph. TriggerControl( ). 29 . All rights reserved. WindowID( ) Determine a window's ID: Reference Guide © 2006 MapInfo Corporation. Create Cartographic Legend. ReadControlValue( ). Alter Menu Item Alter Menu Bar.Chapter 1: Introduction Dialog Boxes Display a standard dialog box: Ask( ). LegendFrameInfo FrontWindow( ). Dialog Remove CommandInfo(CMD_INFO_DLG_OK) Set ProgressBars Alter MapInfoDialog Display a custom dialog box: Dialog handler operations: Determine whether user clicked OK: Disable progress bars: Modify a standard MapInfo Professional dialog box: Menus Define a new menu: Redefine the menu bar: Modify a menu: Modify the menu bar: Invoke a menu command: Query a menu item's status: Create Menu Create Menu Bar Alter Menu. FileSaveAsDlg( ). Menu Bar Run Menu Command MenuItemInfoByHandler( ). MenuItemInfoByID( ) Windows Show or hide a window: Open a new window: Open Window.

Set Graph. StatusBar. Remove Map.5 . Shade. Set Layout. Set Legend. RemoteQueryHandler( ) RemoteMapGenHandler ToolHandler EndHandler ForegroundTaskSwitchHandler React to OLE Automation method: Provide custom tool: React to termination of application: React to MapInfo Professional getting or losing focus: Disable event handlers: Set Handler 30 © 2006 MapInfo Corporation. Control DocumentWindow clause NumWindows( ). Add Cartographic Frame. LayerInfo( ) PrintWin Set Event Processing. Remove Cartographic Frame WindowInfo( ). MapperInfo( ). Alter Cartographic Frame. Set Cartographic Legend. All rights reserved. NumAllWindows( ) Return a window's settings: Print a window: Control window redrawing: Count number of windows: System Event Handlers React to selection: React to window closing: React to map changes: React to window focus: React to DDE request: SelChangedHandler WinClosedHandler WinChangedHandler WinFocusChangedHandler RemoteMsgHandler. Update Window. Add Map. Create Frame. Set Redistricter.Creating the User Interface Modify an existing window: Set Map. Set Browse. MapBasic 8.

RemoteQueryHandler( ). All rights reserved. CommandInfo(CMD_INFO_MSG) Integrated Mapping Set MapInfo Professional 's parent window: Set a Map window's parent: Create a Legend window: Set Application Window Set Next Document Create Legend Special Statements and Functions Launch another program: Return information about the system: Run a string as an interpreted command: Save a workspace file: Load a workspace file or an MBX: Configure a digitizing tablet: Send a sound to the speaker: Set data to be read by CommandInfo: Set duration of the drag-object delay: Reference Guide © 2006 MapInfo Corporation. Run Program SystemInfo( ) Run Command Save Workspace Run Application Set Digitizer Beep Set Command Info Set Drag Threshold 31 .Chapter 1: Introduction Communicating With Other Applications DDE (Dynamic Data Exchange. DDETerminateAll RemoteMsgHandler. Windows Only) Start a DDE conversation: Send a DDE command: Send a value via DDE: Retrieve a value via DDE: Close a DDE conversation: Respond to a request: DDEInitiate( ) DDEExecute DDEPoke DDERequest$( ) DDETerminate.

. . . 2 Sections in this Chapter: Š Š Š New in MapBasic . . . . . . .53 . . . . . .5 product. . . . . . . . . . . . . . . . . . . .New and Enhanced MapBasic Statements and Functions These are the new statements and functions available for the MapInfo Professional 8. . . . . . . . . . . . . . . . . . . . . . . . . . .33 New MapBasic Functions and Statements . . .33 Enhanced MapBasic Functions and Statements. . . . . . . .

Description The Close Connection statement closes the specified connection using the connection handle that is returned from an Open Connection statement. 33 . Syntax Close Connection connection_handle connection_handle is an integer expression representing the value returned from the Open Connection statement. Specifically the addition of Geocoding using remote services as well as IsoGram creation. All rights reserved. Reference Guide © 2006 MapInfo Corporation.5 release of MapInfo Professional. Any service specific properties associated with the connection are lost. We are duplicating them here for your reference.Chapter 2: New and Enhanced MapBasic Statements and Functions New in MapBasic This release of MapBasic includes several new functions as well as the addition of some libraries that facilitate web development and XML file use. New MapBasic Functions and Statements The following new functions have been added to MapBasic for the 8. Close Connection statement on page 33 EPSGToCoordSysString$( ) function on page 34 Geocode statement on page 34 GeocodeInfo( ) function on page 39 IsogramInfo( ) function on page 42 ObjectNodeHasM( ) function on page 44 ObjectNodeHasZ( ) function on page 45 Open Connection statement on page 46 Set Connection Geocode statement on page 48 Set Connection Isogram statement on page 51 Close Connection statement Purpose Closes a connection opened with the Open Connection statement. These functions are included in their place in the logical order of the reference section. Many other functions and statements have been enhanced to allow for new functionality.

Example The following example sets the coordinate system of a map to Earth Projection 1. epsg:2600).PRJ file in your MapInfo Professional installation. For a complete list of EPSG codes used with MapInfo Professional see the MAPINFOW.5 . All rights reserved. Municipality = Municipality_expr.EPSGToCoordSysString$( ) function See Also Open Connection statement EPSGToCoordSysString$( ) function Purpose Converts a string containing a Spatial Reference System into a CoordSys clause that can be used with any MapBasic function or statement. 104. The EPSG codes are identified by a “\p” followed by a number. run command("Set Map " + EPSGToCoordSysString$("EPSG:4326")) See Also CoordSys clause Geocode statement Purpose Geocodes a table or individual value using a remote geocode service through a connection created using the Open Connection statement and set up using the Set Connection Geocode statement. MapBasic 8. Description The EPSGToCoordSysString$( ) is used to convert a SRS String into a CoordSys clause that can be used in any MapBasic function or statement that takes a CoordSys clause as an input. Syntax Geocode connection_number Input [ Table input_tablename ] [ Country = Country_expr [ Street = Street_expr. [ IntersectingStreet = IntersectingStreet_expr ]. 34 © 2006 MapInfo Corporation. SRS strings are also referred to as EPSG (European Petroleum Survey Group) strings (for example. Syntax EPSGToCoordSysString$( epsg_string ) epsg_string is a String describing a Spatial Reference System (SRS) for any supported coordinate systems.

input_tablename is a table alias of an open table including result sets and selections. CountrySubdivision_expr is an expression that specifies the name of a subdivision of a country. CountrySubdiv_column = CountrySubdivision. Municipality_expr is an expression that specifies the name of a municipality. in the US this corresponds to a county. Placename = Placename_expr. PostalCode = PostalCode_expr. in Canada this corresponds to a census division.] . Country_expr is a string expression representing the three letter ISO code for the country. SecondaryPostalCode = SecondaryPostalCode_expr. All rights reserved. CountrySecondarySubdiv_column = CountrySecondarySubdivision. in the US this specifies the name of a state.. CountrySecondarySubdivision= CountrySecondarySubdiv_expr.] [ Interactive [ On [ Max Candidates candidates_expr | All ] [ CloseMatchesOnly [ On | Off ] ] | Off [ First | None ]] connection_number is the number returned when the connection was created. In the US this corresponds to a ZIP+4 extension on a ZIP Code.Chapter 2: New and Enhanced MapBasic Statements and Functions CountrySubdivision = CountrySubdiv_expr. such as a large building that may contain multiple addresses. Placename_column = Placename. In Canada it specifies the name of a province. 35 . SecondaryPostalCode_column = SecondaryPostalCode. ] [ Street_column = Street. For example. For example. Reference Guide © 2006 MapInfo Corporation. Latitude_column = Latitude. MunicipalitySubdivision = MunicipalitySubdiv_expr ] ] Output [ Into [ Table out_tablename [ Key out_keycolumn = in_keyexpr ] ] | [ Variable variable_name ]] [ Point [ On | Off ] [ Symbol Symbol_expr ]. Municipality_column = Municipality. See Open Connection statement on page 434. MunicipalitySubdiv_column = MunicipalitySubdivision. Placename_expr is an expression that specifies the name of a well-known place. PostalCode_column = PostalCode. IntersectingStreet_expr is an expression that specifies a street that should intersect with the street specified in Street_expr. Longitude_column = Longitude Columns colname = geocoder_keyname [. Country_column = Country. SecondaryPostalCode_expr is an expression that specifies a secondary postal code system. CountrySecondarySubdiv_expr is an expression that specifies the name of a secondary subdivision for a country.. ResultCode_column = ResultCode. Street_expr is an expression that specifies a street address. Street2 = Street2_expr. PostalCode_expr is an expression that specifies a postal code.

MunicipalitySubdiv_expr is an expression that specifies the name of a municipality subdivision. PostalCode_column is a string the represents the name of the column to hold the Postal Code result. geocoder_keyname is a string representing the name of a country-specific geocoder item. candidates_expr is an expression that specifies the number of candidates to be returned in an interactive geocoding session. This is used to identify the record from where the geocode came. Symbol_expr is an expression that specifies the symbol to use when displaying a Point from the geometry column. MunicipalitySubdiv_column is a string the represents the name of the column to hold the Municipality Subdivision result. See Symbol clause on page 651 for more information.Geocode statement Street2_expr is an expression that specifies a secondary address line. All rights reserved. Country_column is a string the represents the name of the column to hold the Country result. Municipality_column is a string the represents the name of the column to hold the Municipality result.5 . out_tablename is a table alias of a table to be used as the holder of the data resulting from the geocode operation. ResultCode_column is a string the represents the name of the column to hold the Result Code generated by the geocoder. Street_column is an alias that represents the name of the column to hold the Street result. variable_name is the name of a variable that can hold a single geometry. CountrySubdiv_column is a string the represents the name of the column to hold the Country Subdivision result. Longitude_column is a string the represents the name of the float or decimal column to hold the Longitude result. SecondaryPostalCode_column is a string the represents the name of the column to hold the Secondary Postal Code result. These items are documented by the specific geocoder. out_keycolumn is a string representing the name of a key column in the output table that will be used to hold some identifying “key” from the input records. in_keyexpr is an expression from (the input table) whose value is inserted in the output record. 36 © 2006 MapInfo Corporation. Latitude_column is a string the represents the name of the float or decimal column to hold the Latitude result. MapBasic 8. Placename_column is a string the represents the name of the column to hold the Placename result. colname is a string the represents the name of the column for a geocoder-specific result. CountrySecondarySubdiv_column is a string the represents the name of the column to hold the Country Secondary Subdivision result.

A Country must be specified either as an explicit argument or as a column in input_tablename. these may be more specific than the input. The input_ tablename is optional. In the case of a table. non-table. the entire command returns nothing.based input and output below. However. In general. All rights reserved. The output_tablename is also optional. which must be writable. specify Point On Symbol symbol_expr. 37 . specify Point or Point On (default is on) . This clause creates a relationship between the key columns in the input and output table. The more expressions that are included. The Columns extension allows for data to be returned that is geocoder specific. For example. When a single country is used. the resulting geocode operation would be performed on a set of string inputs (variables or constants). See Table vs. Key is used with Into Table. this requires that the table be mappable. as without it. To do this specify those columns as Latitude = latitude_column Longitude = longitude_ column. When using this output option. To store the point stored into the object column. Output clause The Output clause is required. Note that if the input columns are to be updated. The user must know the names of the keys as defined by the geocoders. ISO standard three letter country codes must be used. so that only a single address is geocoded in each request. however if a table is not specified.Chapter 2: New and Enhanced MapBasic Statements and Functions Description Every Geocode statement must include an Input clause and an Output clause. Whether you want the object created or not. If not specified. The list of fields to include from input_table to be geocoded must include at least one value. it may be possible to geocode an address with just a business name of “MapInfo” and a post code of “12180”. you can still store the x and y values in real number columns. To return the same using a specific symbol. the more accurate your geocoding result will be. they must be specified both for input AND output. Into Table indicates that the Output clause refer to columns in output_table. If you do not want to store the point in the object column. Point specifies that the geographic result of the geocode is to be stored in either the table or the variable. The current default symbol is used. The rest of the output data specifies columns in the output table where well known geocoder return values are stored. the clauses refer to the input_table. much more is returned in the output. Input clause The Input clause is required as a geocode request needs some input data. Variable specifies that the geometry result from the geocode operation is stored in a variable defined in variable_name. Reference Guide © 2006 MapInfo Corporation. it can be a constant string if no data is available. specify Point Off. note that if the input is a table only the first record is processed and the remainder of the records are skipped.

Geocode connectionHandle Input Table nystreets street=StreetName. The default is skipping the record. respecify. Geocode connectionHandle Input Table nystreets municipality=city. If you choose non-table-based input. meaning that the record is skipped. When no value is provided for Max the default is three (3) candidates to be returned. The CloseMatchesOnly setting sets the geocode service to only return close matches as defined by the server. if multiple matches occur the choices are to accept the first candidate or none. or into a variable. • • • • • Interactive is equivalent to Interactive On. All rights reserved. Examples The following example shows a geocode request using the nystreets table and specifying the use of the city. the default is On. country="usa" 38 © 2006 MapInfo Corporation. address=municipality This example shows a geocode request using the nystreets table and specifying a symbol for displaying the output. or cancel the operation.5 . country="usa" OUTPUT StreetName=street. street=StreetName. Streetname. the user is prompted to choose. If you choose to use a table-based input you can have your output placed into either a new or existing table. the output can be placed either into a table or assigned to a variable. If Interactive is specified. the values for the operation must either be expressions (not column names). and postalcode. Interactive Off is equivalent to Interactive Off None. If the Interactive keyword is not included. Interactive clause Interactive [ On | Off ] is an optional keyword that controls whether a dialog box to be displayed in the case of multiple candidates returned for each address. Interactive Off First returns the first candidate in the list. When Off. all results are returned up to the number defined in Max Candidates with the ones that are considered to be close marked as such.based input and output The Geocode statement can be used with any combination of table-based and non-table-based inputs and outputs. countrysubdivision=state. it is equivalent to Interactive Off None and no options can be specified. If CloseMatchesOnly is set to Off. state. When this occurs. variables. When On. If the output is a variable then only the first record is processed and the only value stored is the geographic object. Interactive On Max Candidates All returns all candidates Interactive On Max Candidates 4* myMBVariable/6 returns the number of candidates resulting from the evaluation of the expression. MapBasic 8. non-table. skip. is asked to decide which of the choices is best given the opportunity to skip this input.Geocode statement Table vs. the dialog box displays in these situations. or constant strings. postalcode=zip.

depending on the attribute parameter.DEF. Reference Guide © 2006 MapInfo Corporation.32. indicating which type of information should be returned. Logical. countrysubdivison="NY". GeocodeInfo( ) can also return some status values from the last geocode command issued using each connection.24."MapInfo Cartographic". the return values vary according to the attribute parameter. attribute is an Integer code. or String. country="usa" Output Point Symbol MakeFontSymbol(65. municipality="Troy" Output Variable outvar See Also Open Connection statement GeocodeInfo( ) function Purpose Returns any and all attributes that were set on a connection using the Set Connection Geocode statement. All rights reserved. Syntax GeoCodeInfo( connection_handle. Description The GeoCodeInfo( ) function returns the properties defaulted by the connection or the properties that have been changed using Set GeoCode.Chapter 2: New and Enhanced MapBasic Statements and Functions Output Point Symbol MakeFontSymbol(65. StreetName=street Interactive on Max Candidates 5 The following example shows a Geocode request without using a table and outputting the results into a variable: Geocode connectionHandle Input street="1 Global View". 255 ."MapInfo Cartographic". country="usa". SmallInt. StreetName=street This example sends a request with the Interactive set to On with the return value being placed into the street column. attribute ) connection_handle is an Integer. Integer. In addition.0). All the codes for these values are listed in MAPBASIC.0). 39 . Like many functions of this type in MapBasic.32.24. Geocode connectionHandle Input Table nystreets street=StreetName. Return Value Float. 255 .

SmallInt value representing one of these five values: • • • • • DICTIONARY_ALL 1 DICTIONARY_ADDRESS_ONLY 2 DICTIONARY_USER_ONLY 3 DICTIONARY_PREFER_ADDRESS 4 DICTIONARY_PREFER_USER 5 GEOCODE_STREET_NUMBER GEOCODE_MUNICIPALITY GEOCODE_MUNICIPALITY2 GEOCODE_COUNTRY_SUBDIVISION GEOCODE_COUNTRY_SUBDIVISION2 GEOCODE_POSTAL_CODE GEOCODE_BATCH_SIZE GEOCODE_DICTIONARY GEOCODE_FALLBACK_GEOGRAPHIC Logical representing whether or not the geocoder should fall back to a geographic centroid when other options fail. Logical representing whether or not a match for CountrySecondarySubdivision is set. Logical representing whether or not a match for StreetNumber is set. Integer value representing the batch size. Float value representing the distance from the center of the road that the point is returned. Float value representing the distance from the end of the road that the point is returned. MapBasic 8. All rights reserved. String value representing the units of the center of the road values.5 . Logical representing whether a match for CountrySubdivision is set. Logical representing whether or not the geocoder should fall back to a postal centroid when other options fail. Logical representing whether or not a match for municipality is set.GeocodeInfo( ) function attribute Value GEOCODE_STREET_NAME GeoCodeInfo( ) Return Value Logical representing whether or not a match for StreetName is set. Logical representing whether or not a match for PostalCode is set. GEOCODE_FALLBACK_POSTAL GEOCODE_OFFSET_CENTER GEOCODE_OFFSET_END GEOCODE_OFFSET_CENTER_UNITS 40 © 2006 MapInfo Corporation. Logical representing whether or not a match for MunicipalitySubdivision is set.

3. The case where this occurs is when integer columns are erroneously specified for nonnumeric postal codes. 41 . Logical representing whether MapInfo Professional should change the result code returned from the server by adding an indicator to the result code that the result was based on an arbitrary choice between multiple close matches. GEOCODE_MIXED_CASE GEOCODE_RESULT_MARK_ MULTIPLE GEOCODE_COUNT_NOTGEOCODED GEOCODE_UNABLE_TO_CONVERT_ DATA Reference Guide © 2006 MapInfo Corporation. This option may not be available for all countries. Integer value representing the number of records not geocoded during the last operation. 2. The non-interactive command flag was to pick the first candidate returned rather than none. (see Geocode command “First”). The actual request returned more than one close match for a particular record. The option uses a country specific algorithm that has knowledge of what address parts and what items should be capitalized and what should be made lower case.Chapter 2: New and Enhanced MapBasic Statements and Functions attribute Value GEOCODE_OFFSET_END_UNITS GeoCodeInfo( ) Return Value String value representing the units of the offset from end of street value Logical representing whether MapInfo should format the strings returned in mixed case or leave them as uppercase. The geocoding was not interactive so no possibility of presenting the candidates dialog was possible. This flag only affects the behavior under the following circumstances: 1. GEOCODE_COUNT_GEOCODED Integer value representing the number of records geocoded during the last operation. Logical representing whether a column was not updated during the last operation because of a data type problem. This forces MapInfo to pick one of the candidates. All rights reserved.

or String. Description This function returns the properties defaulted by the connection or the properties that have been changed using the Set Connection Isogram statement. Codes are defined in MAPBASIC. attribute is an Integer code. depending on the attribute parameter. Logical. indicating which type of information should be returned. GEOCODE_PASSTHROUGH + n See Also Open Connection statement. There are two items for each pair.IsogramInfo( ) function attribute Value GEOCODE_PASSTHROUGH GeoCodeInfo( ) Return Value Integer specifying the number of passthrough items set on this connection. MapBasic 8.DEF. Set Connection Geocode statement IsogramInfo( ) function Purpose Returns any and all attributes that were set on a connection using the Set Connection Isogram statement. n is valid up to the value returned via GEOCODE_INFO_ PASSTHROUGH. There are several attributes that IsogramInfo( ) can return. This value is used to know when to stop the enumeration of these values without error. Syntax IsogramInfo( connection_handle.5 . All rights reserved. Return Value Float. attribute ) connection_handle is an integer signifying the number of the connection returned from the Open Connection statement. String values alternately representing name and value for each passthrough pair. attribute setting ISOGRAM_BANDING ISOGRAM_MAJOR_ROADS_ONLY IsogramInfo( ) Return Value Logical representing the Banding option Logical representing the MajorRoadsOnly option 42 © 2006 MapInfo Corporation.

String value representing the distance unit (“mi”. Logical representing the choice of returning only the main polygon of a region. (a percent value represented as a value between 0 and 1 Float value representing the default ambient speed. Integer value representing the maximum number of records that are sent to the service at one time. String value representing the time unit (“hr”.16. Float value representing the Maximum Off Road Distance value The unit string associated with the value ISOGRAM_MAJOR_POLYGON_ONLY ISOGRAM_MAX_OFF_ROAD_DISTANCE ISOGRAM_MAX_OFF_ROAD_DISTANCE_ UNITS ISOGRAM_SIMPLIFICATION_FACTOR Float value representing the Simplification Factor. “sec”). Logical representing the whether or not records that contain non-point objects should be skipped. “km”). Determines the off-road network percentage of the remaining cost (distance) for which off network travel is allowed when finding the Distance boundary. The default value for this property is 0. “min”. Integer value representing the number of records inserted in the last command. The propagation factor is a percentage of the cost used to calculate the distance between the starting point and the Distance. among others.Chapter 2: New and Enhanced MapBasic Statements and Functions attribute setting ISOGRAM_RETURN_HOLES IsogramInfo( ) Return Value Logical representing the choice of returning regions with holes or not. Integer value representing the number of records NOT inserted in the last command. Roads not identified in the network can be driveways or access roads. ISOGRAM_DEFAULT_AMBIENT_SPEED ISOGRAM_DEFAULT_AMBIENT_SPEED_ DISTANCE_UNIT ISOGRAM_DEFAULT_AMBIENT_SPEED_ TIME_UNIT ISOGRAM_DEFAULT_PROPAGATION_ FACTOR ISOGRAM_BATCH_SIZE ISOGRAM_POINTS_ONLY ISOGRAM_RECORDS_INSERTED ISOGRAM_RECORDS_NOTINSERTED Reference Guide © 2006 MapInfo Corporation. All rights reserved. 43 .

The ObjectNodeHasM( ) function supports Multipoint objects and returns TRUE if a specific node in a Multipoint object has an m-value. this tells MapBasic which of the object's nodes should be queried. The node_num parameter must have a value of one or more. z. Dim i_obj_type As SmallInt. Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. hasM as Logical Open Table "routes" Fetch First From routes ' at this point. the program queries if the first node in the object has z-coordinates or m-values and queries z-coordinates and m-values of the first node in the polyline. node_num is a positive integer value indicating which node to read. it returns FALSE. m As Float hasZ. the expression: 44 © 2006 MapInfo Corporation. This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried. polygon_num. Return Value Logical Description The ObjectNodeHasM( ) function returns TRUE if the specific node from a region. If the first object is a polyline. polygon_num is a positive integer value indicating which polygon or section to query. or multipoint object has an m-value. If the object does not support m-values or an m-value for this node is not defined. Example The following example queries the first graphic object in the table Routes. polyline.5 . All rights reserved. Syntax ObjectNodeHasM( object.ObjectNodeHasM( ) function See Also Create Object statement. Open Connection statement. Set Connection Isogram statement ObjectNodeHasM( ) function Purpose Returns TRUE if a specific node in a region. node_num ) object is an Object expression. The polygon_num parameter must have a value of one or more. polyline or multipoint object has an m-value. MapBasic 8. It is ignored for Multipoint objects (it used for regions and polylines). You can use the ObjectInfo( ) function to determine the number of nodes in an object.

1)) Then z = ObjectNodeZ(routes. All rights reserved. You can use the ObjectInfo( ) function to determine the number of nodes in an object. Return Value Logical Description The ObjectNodeHasZ( ) function returns TRUE if a specific node from a region. 1) ' read m-value End If End If See Also Querying Map Objects.. 1. This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried. The node_num parameter must have a value of one or more. Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. The ObjectNodeHasZ( ) function supports Multipoint objects and returns TRUE if a specific node in a Multipoint object has a z-coordinate.obj ' represents the graphical object that's attached ' to the first record of the routes table. 1) ' read z-coordinate End If If (ObjectNodeHasM(routes. 1)) Then m = ObjectNodeM(routes. The polygon_num parameter must have a value of one or more. this tells MapBasic which of the object's nodes should be queried. or multipoint object has a z-coordinate.. If (ObjectNodeHasZ(routes. node_num ) object is an Object expression. If object does not support z-coordinates or a z-coordinate for this node is not defined. 1. polyline.obj. 1. It is ignored for Multipoint objects (it used for regions and polylines). polygon_num.. ObjectInfo( ) function ObjectNodeHasZ( ) function Purpose Returns TRUE if a specific node in a region. 1.obj.obj. i_obj_type = ObjectInfo(routes. or multipoint object has a z-coordinate Syntax ObjectNodeHasZ( object.obj. it returns FALSE. Reference Guide © 2006 MapInfo Corporation. node_num is a positive integer value indicating which node to read. 45 .. then the object is a polyline. OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' .obj. polygon_num is a positive integer value indicating which polygon or section to query. polyline.Chapter 2: New and Enhanced MapBasic Statements and Functions ' routes.

hasM as Logical Open Table "routes" Fetch First From routes ' at this point. the program queries if the first node in the object has z-coordinates or m-values and queries z-coordinates and m-values of the first node in the polyline. 1. i_obj_type = ObjectInfo(routes. then the object is a polyline.obj.obj. 1. 1.obj ' represents the graphical object that's attached ' to the first record of the routes table. pwd_string is a string representing the password corresponding to user_name.. MapBasic 8..obj. 1)) Then m = ObjectNodeM(routes. ObjectInfo( ) function Open Connection statement Purpose Creates a connection to an external geocode or Isogram service provided by a MapMarker or Envinsa server. If the first object is a polyline. 46 © 2006 MapInfo Corporation. m As Float hasZ. 1) ' read m-value End If End If See Also Querying Map Objects.5 . z. All rights reserved. the expression: ' routes. Dim i_obj_type As SmallInt.obj. 1.. If (ObjectNodeHasZ(routes. var_name is a string representing the variable which will hold the returned connection number. or to a geocoding service if you are specifying Geocode. URLString must be a valid URL to a routing service if you are specifying Isogram. Syntax Open Connection Service Geocode [ MapMarker | Envinsa ] | Isogram URL URLstring [ User name_string [ Password pwd_string ] ] [ Interactive [ On | Off ] ] into variable var_name URLString is a string representing a valid URL. 1)) Then z = ObjectNodeZ(routes.obj. name_string is a string representing the user name for an Envinsa or MapMarker installation.Open Connection statement Example The following example queries the first graphic object in the table Routes. 1) ' read z-coordinate End If If (ObjectNodeHasM(routes. OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' ..

If the service is Geocode and no service provider is specified. The Into variable keywords are required as var_name is the variable that holds the returned connection number that is then passed to other statements. The following example opens a geocoding connection without Interactive specified. Interactive is set to Off by default. All rights reserved. However. 47 . and the Create Object Isogram statement. the Set Connection Isogram statement. Open Connection Into Variable CnctNum Service Geocode URL "http:// EnvinsaServices/LocationUtility/services/LocationUtility" Interactive On This example opens a geocode connection with a server that requires authentication. With Interactive specified to Off. it is equivalent to Interactive On. it is the same as Interactive Off. no dialog box is displayed and the command fails if the authentication fails. the dialog box appears if the authentication fails. the Geocode statement. Interactive determines whether a username/password dialog box is shown if and only if the credentials passed in for authentication are not adequate. Since the Isogram service is only provided by Envinsa no provider can be specified.Chapter 2: New and Enhanced MapBasic Statements and Functions Description The Open Connection statement creates a connection to a Geocode or Isogram service. Open Connection Into Variable CnctNum Service Geocode URL "http:// EnvinsaServices/LocationUtility/services/LocationUtility" This example opens a geocode connection and specifies Interactive as On. such as the Set Connection Geocode statement. if Interactive is specified. Examples Note: All examples without the keyword MapMarker assume Envinsa. That is. dim baseURLVariable as String baseURLVariable = "http://EnvinsaServices/” Open Connection Service Geocode URL baseURLVariable + "LocationUtility/ services/LocationUtility" User "geocodeuser" Password "GeoMe" Into Variable CnctNum This example opens an Isogram connection with a server that requires authentication. The default for the command is Interactive Off. if the Interactive keyword is not used at all. Each statement must specify a service and provider to which the connection is being established. Envinsa is assumed. dim baseURLVariable as String baseURLVariable = "http://EnvinsaServices/” Open Connection Service IsoGram URL baseURLVariable + "Route/services/ Route" User "isogramuser" Password "ISOMe" Into Variable CnctNum Reference Guide © 2006 MapInfo Corporation. With Interactive specified as On.

]] [ StreetNumber [ On | Off ] [. name value. batch_size is an integer expression that specifies the maximum number of records that are sent to the service at one time. offset_num_expr is a numeric expression which specifies the offset from either the corner (end) or the center of the street.]] [ CountrySubdivision[ On | Off ] [.] ] ] [ Dictionary [ All | Address | User | Prefer ( Address | User ) ] [ Offset [ [ Center offset_num_expr Units distance_unit_name ] [ End offset_num_expr Units distance_unit_name ] [ PassThrough name value. ] connection_number is a number that specifies the connection handle created using the Open Connection statement. distance_unit_name is a String that represents the units in which offset_num_expr are expressed. Set Connection Geocode statement.]] [ CountrySecondarySubdivision [ On | Off ] [.. These values are just to offset the point returned from the center of the street or the end of the street respectively.5 .] ] | All [ On | Off ] [. All rights reserved.Set Connection Geocode statement See Also Close Connection statement. The connection needs to have been already created using the Open Connection statement.]]] [ Fallback [ Geographic [ On | Off ] [.] ] [ PostalCode [ On | Off ] [. Set Connection Isogram statement Set Connection Geocode statement Purpose Configures a connection to a remote service with options for geocoding. .] ] [ PostalCode [ On | Off ] [. Syntax Set Connection connection_number Geocode [ Batch Size batch_size ] [ ResultCode MarkMultiple [ On | Off ] ] [ MixedCase [ On | Off ] ] [ Match [ StreetName [ On | Off ] [. name is a the name part of the parameter pair that is passed through to the geocoding service.] ] [ MunicipalitySubdivision [ On | Off ] [. value is the value part of the parameter pair that is passed through to the geocoding service.. MapBasic 8. 48 © 2006 MapInfo Corporation.]] [ Municipality [ On | Off ] [.

Match MunicipalitySubdivision indicates whether or not the municipality subdivision should be relaxed when trying to match. the user has a better opportunity to cancel the request. 49 . For example. So if a particular preference is stated. Match CountrySecondarySubdivision indicates whether or not the country secondary subdivision should be relaxed when trying to match. Match CountrySubdivision indicates whether or not the country subdivision (usually a state or province) should be relaxed when trying to match. If this number is high. it is the same as setting it to On. For example. and PassThrough. A Set Connection statement is composed of six different sub-clauses. the geocoder only considers inputs that fully match the name in the geocode data as a close match. Reference Guide © 2006 MapInfo Corporation. Match All sets all the match properties to On or Off . Match StreetName indicates whether or not the street name should be relaxed when trying to match. Match StreetNumber indicates whether or not the address number should be relaxed when trying to match. Note this can be used in combination with other match options. Match PostalCode Off turns all the match parameters on and just the postal code match is turned off. Match. any remaining batches are not processed Match Clause If a specific Match is set. Match PostalCode indicates whether or not the postal code should be relaxed when trying to match.Chapter 2: New and Enhanced MapBasic Statements and Functions Description The Set Connection statement is used to assign geocode preferences already defined so that each geocode request does not need to reiterate the preferences defined. if Match StreetName is On. If this number is low. Offset. the geocoder does not regard street name inputs that do not match the name in the geocode data. Batch Clause The Batch clause determines the maximum number of records that are sent to the service at one time. These clauses are Batch. This allows you to optimize the processing of records to balance the amount of time needed by the local computer and the external service. as close matches. Match All On. Fallback. you will have longer local downtime while the service processes the records. If you cancel the command. Set Connection connectionHandle Geocode Match Municipality is equivalent to Set Connection connectionHandle Geocode Match Municipality On. Match Municipality indicates whether or not the municipality should be relaxed when trying to match. All rights reserved. For the individual preferences under Match the default is On. Dictionary. For example. Once a batch is sent to the service it cannot be cancelled.

PassThrough Clause PassThrough is a set of name/value pairs that are sent to the geocoder. set connection MapMarkerHandle1 geocode match streetname. postalcode. Dictionary Prefer Address means use both dictionaries and prefer the address dictionary. The five possible choices for the Dictionary clause are: • • • • • Dictionary All means use both the user and address dictionaries.5 . Units is a String that describes the units in which Offset Center and Offset End are measured. PassThrough "KEY_CASS_RULES" "true" See Also Geocode statement. countrysubdivision The following example adds a PassThrough clause to a Set Connection statement. streetnumber. These are pairs are geocode service specific and are documented by the particular geocode service. municipalitysubdivision. All rights reserved. Offset Clause Offset End indicates the distance that a point location is adjusted from a street corner. This particular example turns on CASS certified results in the US. municipality. Open Connection statement 50 © 2006 MapInfo Corporation. Dictionary Clause Dictionary indicates the combination of MapMarker address dictionary and configured user dictionaries to use during the geocode process. Dictionary User means use only the User dictionary. If the record does not contain a street address. Fallback Postal indicates whether or not to geocode to the postal centroid if a street level geocode cannot be performed. See Set Distance Units statement on page 570 for the list of available unit names. this value has no impact. This value is only appropriate when your address to be geocoded includes a street address. MapBasic 8. Dictionary Prefer User means use both dictionaries and prefer the User dictionary. Dictionary Address means use only the address dictionary. Offset Center indicates the distance that a point location is adjusted from a street center line. Example The following example sets a connection to a geocoder with some match options turned on.Set Connection Geocode statement FallBack Clause Fallback Geographic indicates whether or not to geocode to the geographic centroid for the input address if a street level geocode cannot be performed.

if 10. 20. Thus it represents the time or distance from the smaller region edge to its edge. “min” and “sec”. propagation_factor is a Float value specifying the default propagation factor. The number is expressed in distance_units and time_units. Syntax Set Connection connection_handle Isogram [ Banding [ On | Off ] ] [ MajorRoadsOnly [ On | Off ] ] [ MaxOffRoadDistance distance_value Units distance_units ] [ ReturnHoles [ On | Off ] ] [ MajorPolygonOnly [ On | Off ] ] [ SimplificationFactor simplification ] [ PointsOnly [ On | Off ] ] [ DefaultAmbientSpeed ambient_speed Units distance_units Per time_units ] [ DefaultPropagationFactor propagation_factor ] [ Batch Size batch_size ] connection_handle is a the number of the connection returned from the Open Connection statement. For example. batch_size is an integer expression that specifies the size of each batch that is sent to the service. time_units is a string that specifies time units. 51 . simplification is a Float value that controls the density of nodes in the output region as a percentage. The default is 2 and the maximum limit is 50. The value can be from 0 to 1 inclusive. the regions returned for one point will not overlap. For a complete list of valid strings of distance units. see Set Distance Units statement on page 570.Chapter 2: New and Enhanced MapBasic Statements and Functions Set Connection Isogram statement Purpose Allows a user to set options for an Isogram connection. Description The Set Connection Isogram statement configures the connection that is to be used for creating an Isogram object (using the Create Object statement). The value can be from 0 to 1 inclusive. All rights reserved. distance_units is a string that specifies the distance units in which the specific distance_value is expressed. Banding applies only if multiple distances or times are specified in the Isogram operation. Valid values are “hr”. and Reference Guide © 2006 MapInfo Corporation. The smaller region is cut out of the result. ambient_speed is a numeric value specifying the default ambient speed . If On. distance_value is a Float value that specifies the maximum distance travel will be allowed to go off roads in the network.

01 being 1%). Set Connection iConnect Isogram Banding On MajorRoadsOnly On MaxOffRoadDistance 2 Units "mi" ReturnHoles On MajorPolygonOnly On SimplificationFactor . All rights reserved. The default value for this property is 0. Isogram generation is substantially quicker when using MajorRoadsOnly. A lower number improves responsiveness of the command and lowers the chance of a time-out and service failure. DefaultPropagationFactor is used only for Distances. The propagation factor is a percentage of the cost used to calculate the distance between the starting point and the maximum distance. MajorRoadsOnly determines whether or not only major roads are used in the calculation of the Isogram. A syntax example is: DefaultAmbientSpeed 12 "mi" Per "hr" DefaultPropagationFactor determines the off-road network percentage of the remaining cost (distance) for which off network travel is allowed when finding the maximum distance boundary. SimplificationFactor specifies the reduction factor for polygon complexity. PointsOnly specifies whether or not records that contain non-point objects should be skipped. MapBasic 8. among others.01 and 1. This may effect performance and responsiveness.05 DefaultAmbientSpeed 50 Units "mi" Per "hr" DefaultPropagationFactor .16. the 20 minute Isogram represents the areas accessible from 10 to 20 minutes and the 30 minute Isogram the area from 20 to 30 minutes. The simplification factor indicates what percentage of the original points should be returned or that the resulting polygon should be based on. The default value is 2.0 (1 being 100% and 0. Open Connection statement 52 © 2006 MapInfo Corporation.5 .2 Batch Size 2 Point On See Also Create Object statement. The acceptable range is between 0. Batch Size sets the number of records to send to the server to be processed at once.Set Connection Isogram statement 30 minutes Isograms are requested.01 and 1.The default value is 0.05. The polygon or set of points may contain many points. Lower numbers mean fewer points in the region and therefore faster transmission times across the Internet connection. Roads not identified in the network can be driveways or access roads. The simplification factor is a float number between 0. DefaultAmbientSpeed is used only when specifying time. Examples The following example shows a Set Connection Isogram statement. MajorPolygonOnly indicates that the Region returned has only one outer polygon. all the regions cover the area accessible from 0 to the time or distance specified. If Off. If a large request is sent it will take longer for the Isogram to be returned and therefore longer for Mapinfo Professional to respond to cancel requests and update the Progress Bar dialog box. ReturnHoles indicates whether or not holes should be returned in the resulting region. MaxOffRoadDistance specifies the maximum distance travel is allowed to go off roads.

53 .. ] ] Connection connection_handle [ Distance dist1 [[ Brush brushclause ] [ Pen penclause ]] [. distN [ Brush brushclause ] [ Pen penclause ] [....Chapter 2: New and Enhanced MapBasic Statements and Functions Enhanced MapBasic Functions and Statements The following functions have been modified in this release of MapBasic.. column = expression. Syntax 3 (Isogram-specific) Create Object As Isogram From fromtable [ Into { Table intotable } ] [ Data column = expression [ . time2 [ Brush brushclause ] [ Pen penclause ]] [. We are including links in each case to the full description within the Reference Guide. IsoGrams are regions that are within a specific distance or travel time from a specific point..] Units time_unit ] Reference Guide © 2006 MapInfo Corporation. Create Object statement on page 53 Create Redistricter statement on page 55 LocateFile$( ) function on page 55 MapperInfo( ) function on page 56 ObjectGeography( ) function on page 56 Open Table statement on page 57 Open Window statement on page 57 SessionInfo( ) function on page 57 Set Map statement on page 58 Set Redistricter statement on page 59 Set Window statement on page 59 Shade statement on page 60 TableInfo( ) function on page 61 UnitAbbr$( ) and UnitName$( ) functions on page 61 WindowInfo( ) function on page 61 Create Object statement The Create Object statement has been enhanced to now include the creation of Isograms. All rights reserved. dist2 [ Brush brushclause ] [ Pen penclause ]] [. The listings included here are only the changed aspects of each function and statement.. timeN [ Brush brushclause ] [ Pen penclause ]] [.] Units dist_unit ] [ Time time1 [[ Brush brushclause ] [ Pen penclause ]] [..

MapBasic 54 © 2006 MapInfo Corporation. Isogram If the Create Object statement performs an Isogram operation. and the object is a linear object (line. If you do not specify a Brush clause or Pen clause the current brush and pen is used. and if the source object is a closed object. All rights reserved. indicating the number of segments per circle in a Buffer operation. using the Set Connection Isogram statement with MajorRoadsOnly specified. By specifying a Time clause. See Set Distance Units statement on page 570 for a complete list of possible values. expression is an expression used to populate column. 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. brushclause is a valid Brush clause. dist_unit is a valid unit of distance. dist1. the resulting buffer is smaller than the source object. The Distance clause can contain one or more distance expressions with an optional brush and/or pen for each one. Many items factor into the equation. penclause is a valid Pen clause. you can create regions based on time. if this number is negative. arc) or a point. The maximum amount of values allowed is 50. intotable is the name of an open table where the new object(s) will be stored. containing one or more graphic objects. If you do not specify a Brush clause or Pen clause the current brush and pen is used. connection_handle is a number expression returned from the Open Connection statement referencing the connection to be used. timeN are numeric values representing times for Isograms expressed in time_units. or “sec”. Each value creates a separate band that can be either specific times or specific distances. distN are numeric expressions representing distances for the Isograms expressed in dist_units. bufferwidth is a number indicating the displacement used in a Buffer operation. results in a much quicker response compared to using the entire road network. dist2. dist_unit is the name of a distance unit (for example. “min”. column is the name of a column in the table. you must pass a connection_handle that corresponds to an open connection created with an Open Connection statement. then the absolute value of width is used to produce a positive buffer. You must specify a Distance clause or a Time clause to create the size of the Isogram desired. Larger values take substantially longer to create. with each one having an optional Brush clause and/or Pen clause. “km” for kilometers). but in general. time_unit is a string representing valid unit of time. 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. polyline. If the width is negative. Valid choices are: “hr”. smoothness is an integer from 2 to 100. time1.5 .Create Object statement fromtable is the name of an open table. time2. MapBasic 8.

the maximum time is 2 hours with MajorRoadsOnly Off and 8 hours with MajorRoadsOnly On.xml). XML list of routing servers (MIRoutingServers.xml). XML list of WFS servers (MIWFSServers. Value LOCATE_WMS_SERVERLIST LOCATE_WFS_SERVERLIST LOCATE_GEOCODE_SERVERLIST LOCATE_ROUTING_SERVERLIST Description XML list of WMS servers (MIWMSServers. All rights reserved. See Create Object statement Create Redistricter statement The Create Redistricter statement has a new Percentage clause the defines the in-row mode of percentage calculation. See LocateFile$( ) function Reference Guide © 2006 MapInfo Corporation.Chapter 2: New and Enhanced MapBasic Statements and Functions only allows distances of 150 miles with MajorRoadsOnly Off and 600 miles with MajorRoadsOnly On. XML list of geocode servers (MIGeocodeServers. [ Percentage from expr ] where expr is a numeric expression. See Create Redistricter statement LocateFile$( ) function The LocateFile$( ) function has been enhanced to include four values that can be passed to find new XML files that are implemented with this release of MapInfo Professional and MapBasic.xml).xml). the default is to use the in-column mode. 55 . If no Percentage clause is specified. similarly.

See ObjectGeography( ) function 56 © 2006 MapInfo Corporation. then. The value can be either: • • • None . OBJ_GEO_POINTZ OBJ_GEO_POINTM Z-value of a Point object. All rights reserved.MapperInfo( ) function MapperInfo( ) function The MapperInfo( ) function has been updated to return the MapBasic statements that a user would need to drop a Map window onto the current Map window. MAPPER_INFO_REPROJECTION MAPPER_INFO_RESAMPLING String value indicating the method for calculating the pixel values of the source image being reprojected. MapBasic 8.5 . error is set. String value indicating the current value of the reprojection mode. Always . MAPPER_INFO_MERGE_MAP String value: the string of MapBasic statements that a user needs to merge one map window into the current Map window.Optimize whether or not to reproject the map. M-value of a Point object. The function has also been enhanced to be able to query about reprojection parameters.Always reproject the map. The value can be either: • • CubicConvolution NearestNeighbor See MapperInfo( ) function ObjectGeography( ) function If object does not support z/m values or z/m-value for this node is not defined.Never reproject the map. allow Mapinfo Professional to decide. Auto .

VMRaster treats Vertical Mapper GRD files as Raster Layers when opened. Note: This dialog box is not strictly a window so does not have an entry in MAPBASIC. TableList A dialog box that displays a list of currently opened tables. All rights reserved. String result that indicates a session's area units. area units. SESSION_INFO_DISTANCE_UNITS SESSION_INFO_AREA_UNITS SESSION_INFO_PAPER_UNITS String result that indicates a session's distance units. See Open Table statement Open Window statement The Open Window statement has been enhanced with an option to open the TableList dialog box. and paper units. Users of Vertical Mapper want to be able to have their VM tables be recognized as grid and raster tables within MapInfo Professional. Syntax Open [ [ [ Table filename [ As tablename ] Hide ] [ ReadOnly ] [ Interactive ] [ Password pwd ] NoIndex ] [ View Automatic ] [ DenyWrite ] VMGrid | VMRaster ] VMGrid treats Vertical Mapper GRD files as Grid Layers when opened.DEF See Open Window statement SessionInfo( ) function The SessionInfo( ) function has been updated to return information about the session’s distance units. these new keywords enable that when they open these tables within MIPro. String result that indicates a session's paper units. Reference Guide © 2006 MapInfo Corporation.Chapter 2: New and Enhanced MapBasic Statements and Functions Open Table statement The Open table statement has had the VMGrid and VMRaster keywords added to the statement to enable users to be able to take full advantage of the grid and raster tools in MapInfo Professional. 57 .

then the old MI Pro code works. specifically. from one cartographic projection into another projection. in general) of the basic pixel are calculated for every pixel of the destination image based on special optimized procedure. NearestNeighbor is a method of resampling images by merely putting the value of the basic pixel from a source image into the current pixel position. Resampling is a method of restoring the pixel value (usually proportional to the brightness of a spot on the ground object covered by the instant field of view of the image sensor) of the destination raster image based on the source image: a set of pixel values being a discrete representation of the initial continuous brightness field. . Always and Auto: Always means that reprojection is always done.. The coordinates (real numbers. i..e. This is the fastest way of drawing resulting images. a pixel of the destination image is calculated based on the pixel values in a 4x4 window centered at the “basic” pixel in the source image. standard Windows functions are used for only stretching the source image in both directions. If it looks as a “rigorous” rectangle (two sides are parallel to x-axis and two sides parallel to y-axis). All rights reserved. Reprojection is the geometric transformation of a raster image. MapBasic 8. See Set Map statement 58 © 2006 MapInfo Corporation. Here. Pixels within the above window are weighted in a special way based on the mantissas of basic pixel coordinates. coordinates are calculated using precise formulae and pixels are resampled using “cubic convolution” or “nearest neighbor”. the new reprojection code works. This is also referred to as warping. { Image Reprojection { None | Always | Auto } ] [ Image Resampling { CubicConvolution | NearestNeighbor } ] CubicConvolution is a method of resampling images providing for the best “restoration” of pixel values unavailable in a source image (because of its discreteness). If the above is not the case (stretching is not enough because of non-linearities and/or skew of the destination image rectangle transformed into the source image space).5 . Auto means that usage of reprojection is decided based on how the destination image rectangle looks after having been transformed into the source image space.Set Map statement See SessionInfo ( ) function Set Map statement The Set Map statement has been enhanced to include keywords that facilitate image reprojection and resampling.

Syntax Set Window window_id . Currently MapInfo supports 6 different filters as listed in the table below. threshold_value should be in the range from 0 to 255. Antialiasing determines whether anti-aliasing filter is used during image exporting. 59 . Only pixels with values above threshold_value are smoothed.. Reference Guide © 2006 MapInfo Corporation. For example. fill patterns are scaled based on the ratio of the output device’s resolution to the screen resolution. If threshold_value is set to zero. [ Scale Patterns { On | Off [ Scale Patterns { On | Off [ Antialiasing { On | Off } [ Threshold threshold_value [ MaskSize size_value ] [ Filter filter_value ] } ] } ] ] ] If Scale Patterns is set to On. [ Printer { Default | . Syntax 3 Set Redistricter districts_table Percentage from { column | row } See Set Redistricter statement Set Window statement The Set Window statement now can specify to scale patterns as well as perform anti-aliasing for printing images. Antialiasing is ignored when images are exported to EMF or WMF formats.Chapter 2: New and Enhanced MapBasic Statements and Functions Set Redistricter statement The set Redistricter statement has a new syntax added that enables switching between the two modes of percentage calculation. MaskSize specifies a value that indicates the size of the anti-aliasing mask.. All rights reserved. Filter specifies which anti-aliasing filter to apply. The application of the antaliasing filter on the image associates a value with each pixel. than all pixels are smoothed. then the resulting image can become too blurry.. Threshold specifies a value that indicates which pixels to smooth. a value of three indicates an anti-aliasing mask of 3x3. If user sets mask size_value too high..

..Shade statement Filter FILTER_VERTICALLY_AND_ HORIZONTALLY FILTER_ALL_DIRECTIONS_1 FILTER_ALL_DIRECTIONS_2 Description Anti-alias image vertically and horizontally. The filter used for this option is different than FILTER_ ALL_DIRECTIONS_1 and gets better results for anti-aliasing text.. See Shade statement 60 © 2006 MapInfo Corporation.5 . Anti-alias image diagonally. Anti-alias image in all directions Anti-alias image in all directions. Syntax 2 (shading by individual values) Shade [ Window window_id ] { layer_id | layer_name } With Metadata . Anti-alias image horizontally Anti-alias image vertically FILTER_DIAGONALLY FILTER_HORIZONTALLY FILTER_VERTICALLY See Set Window statement Shade statement The Shade statement has been enhanced to allow the use of metadata in the creation of a theme. MapBasic 8.. If you specify With Metadata. All rights reserved. any theme metadata contained in the open table is used to create the Individual or Ranged Value theme. Syntax 1 (shading by ranges of values) Shade [ Window window_id ] { layer_id | layer_name } With Metadata .

WIN_INFO_EXPORT_THRESHOLD (42) Reference Guide © 2006 MapInfo Corporation. TRUE if the table has default theme metadata. TAB_INFO_THEME_ METADATA See TableInfo( ) function UnitAbbr$( ) and UnitName$( ) functions These functions now can operate on time units: hours (“hr”). Integer value between 0 and 255 that specifies anti-aliasing threshold. 61 . See UnitAbbr$( ) function and UnitName$( ) function WindowInfo( ) function The WindowInfo( ) function has four additional values of window_spec to allow for the querying of anti-aliasing features of a window. Logical result. and seconds (“sec”). TAB_INFO_BROWSER_LIST String result indicates which columns will be displayed in a Browser window. Return empty string if this information is absent. This information is stored in table metadata.Chapter 2: New and Enhanced MapBasic Statements and Functions TableInfo( ) function The TableInfo( ) function has been updated to return information about which columns are returned in a Browser window and whether or not a table contains theme metadata. minutes (“min”). Value of window_spec WIN_INFO_EXPORT_ANTIALIASING (41) Description String value: ON if a anti-aliasing filter will be used for exporting. All rights reserved. OFF otherwise.

All rights reserved.WindowInfo( ) function Value of window_spec WIN_INFO_EXPORT_MASKSIZE (43) WIN_INFO_EXPORT_FILTER (44) Description Integer value between 0 and 100 Integer value that return one of possible antialiasing filters: • • • • • • FILTER_VERTICALLY_AND_ HORIZONTALLY.5 . FILTER_ALL_DIRECTIONS_1 FILTER_ALL_DIRECTIONS_2 FILTER_DIAGONALLY FILTER_HORIZONTALLY FILTER_VERTICALLY See WindowInfo( ) function 62 © 2006 MapInfo Corporation. MapBasic 8.

through the MapBasic window. Most MapBasic statements can be typed directly into MapInfo Professional.” “You cannot issue a For…Next statement through the MapBasic window”). the Restrictions section identifies the limitation. Example A brief example. Syntax The format in which you should use the function or statement and explanation of argument(s). If a statement may not be entered through the MapBasic window.A – Z Reference 3 The next section describes the MapBasic language in detail. Each is described in the following format: Purpose Brief description of the function or statement. “The DDEInitiate function is only available under Microsoft Windows. Restrictions Information about limitations (for example. Generally. flow-control statements (such as looping and branching statements) cannot be entered through the MapBasic window. . Description Thorough explanation of the function or statement's role and any other pertinent information. You will find both statements and function descriptions arranged alphabetically. Return Value The type of value returned by the function. See Also Related functions or statements.

inclusive. f_y As Float f_x = -2. Return Value Float 64 © 2006 MapInfo Corporation. Syntax Acos ( num_expr ) num_expr is a numeric expression between one and negative one.Abs( ) function Abs( ) function Purpose Returns the absolute value of a number. Return Value Float Description The Abs( ) function returns the absolute value of the expression specified by num_expr.5 See Also Sgn( ) function Acos( ) function Purpose Returns the arc-cosine value of a number. Abs( ) returns a value equal to the value of num_expr multiplied by negative one (-1). All rights reserved. MapBasic 8.5 . Example Dim f_x. Syntax Abs ( num_expr ) num_expr is a numeric expression. If num_expr has a negative value.5 f_y = Abs(f_x) ' f_y now equals 2. If num_expr has a value greater than or equal to zero. Abs( ) returns a value equal to num_expr.

. To convert a degree value to radians. multiply that value by RAD_2_DEG.. Your program must Include MAPBASIC. and given that Pi/2 radians represents 90 degrees).141593.DEF in order to reference DEG_2_RAD or RAD_2_DEG. the expression num_expr should represent a value no larger than one and no smaller than negative one. In other words. 65 . ] ] [ SubTitle [ frame_subtitle ] [ Font. Since cosine values range between one and negative one. ] ] [ Border Pen. ' since the cosine of 60 degrees is 0. ] ] [ Default Frame Subtitle { def_frame_subtitle } [ Font. ] ] [ Default Frame Style { def_frame_style } [ Font.DEF" Dim x. Syntax Add Cartographic Frame [ Window legend_window_id ] [ Custom ] [ Default Frame Title { def_frame_title } [ Font... multiply that value by DEG_2_RAD. Reference Guide © 2006 MapInfo Corporation. ] ] [ Default Frame Border Pen. Cos( ) function. The result returned from Acos( ) represents an angle.. expressed in radians. To convert a radian value into degrees.5 y = Acos(x) * RAD_2_DEG ' y will now be equal to 60. Tan( ) function Add Cartographic Frame statement The Add Cartographic Frame statement allows you to add cartographic frames to an existing cartographic legend created with the Create Cartographic Legend statement..] [ NoRefresh ] [ Text { style_name } { Line Pen. ] [ Style [Font...5 See Also Asin( ) function.Add Cartographic Frame statement Description The Acos( ) function returns the arc-cosine of the numeric num_expr value... This angle will be somewhere between zero and Pi radians (given that Pi is equal to approximately 3.. pen_expr ] Frame From Layer { map_layer_id | map_layer_name } [ Position ( x . Example Include "MAPBASIC.... Sin( ) function... y As Float x = 0. All rights reserved. Atn( ) function. y ) [ Units paper_units ] ] [ Using [ Column { column | object [ FromMapCatalog { On | Off }]} ] [ Label { expression | default } ] [ Title [ frame_title ] [ Font... Acos( ) returns the angle whose cosine is equal to num_expr.

Brush.g. The upper left corner of the legend window has the position 0. 66 © 2006 MapInfo Corporation. then each frame section must include a Position clause.. line. ] legend_window_id is an integer window identifier which you can obtain by calling the FrontWindow( ) function and WindowID( ) function. It can include the special character “#” which will be replaced by the current layer name. color ). frame_title is a string which defines a frame title.5 . Position values use paper units settings. “Point. . MakePen( width.. then it is used instead of the default. 0. For example. If Custom is omitted and the legend is laid out in portrait or landscape. pen_expr is a Pen expression. Description If the Custom keyword is included. or the object column (meaning that legend styles are based on the unique styles in the mapfile).. style_name is a string which displays next to a symbol. e.. If a border pen clause exists at the frame level.. a MapBasic program can change this setting through the Set Paper Units statement.. such as “in” (inches) or “cm” (centimeters).. ] ] [ . as appropriate for the symbol. or region in a custom frame. map_layer_id or map_layer_name identifies a map layer. If a SubTitle clause is defined here for a frame. The Position clause controls the frame's position on the legend window. “% of #” will expand to “Region of States” for the states.. which defaults to inches. then the frames will be added to the end. use 1 to specify the top map layer other than Cosmetic) or a string representing the name of a table displayed in the map. then it will be used instead of the def_frame_title.g.. then it will be used instead of the def_frame_subtitle. column is an attribute column name from the frame layer's table.. For a theme layer you must specify the map_layer_id. then it will be become the default for the frame. “Region”.You can override the current paper units by including the optional Units subclause within the Position clause. 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. pattern. def_frame_title is a string which defines a default frame title. The default is 'object'..Add Cartographic Frame statement | Region Pen. The “%” character will be replaced by the text “Line”. If a Title clause is defined here for a frame. paper_units is a string representing a paper unit name (for example. The “#” character will be replaced with the layer name. If a default border pen is defined. MapBasic 8. | Symbol Symbol. MapBasic has a current paper units setting. All rights reserved. can be a SmallInt (e. frame_subtitle is a string which defines a frame subtitle.tab layer. “cm” for centimeters). def_frame_style is a string that displays next to each symbol in each frame. .

column is the name of a new column to add to that table. Region. Label is a valid expression or default (meaning that the default frame style pattern is used when creating each style's text. This is done with the Text and appropriate Line. If the table is not a live access table. or Symbol clause. This table must be a live access table that supports per record styles for this to occur. The default behavior for a non-access table is FromMapCatalog Off (i. FromMapCatalog OFF retrieves the unique map styles for the live table from the server. the Style clause must contain your custom list of definitions for the styles displayed in the frame. Remove Cartographic Frame statement Add Column statement Purpose Adds a new. map styles).. const . Set Cartographic Legend statement.. then the table is not scanned for styles. temporary column to an open table. Syntax Add Column table ( column [ datatype ] ) { Values const [ . we do not write it to the workspace since it is default behavior. FromMapCatalog ON retrieves styles from the MapCatalog for a live access table.Add Column statement The defaults in this statement apply only to the frames being created in this statement. This lets us avoid bumping up the workspace version in this case. 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 FromMapCatalog ON clause is specified. or updates an existing column with data from another table. If the NoRefresh keyword is used in the Style clause. If the live table does not support per record styles than the behavior is to revert to the default behavior for live tables. Reference Guide © 2006 MapInfo Corporation. the FromMapCatalog OFF clause is written to the workspace when specified. See Also Create Cartographic Legend statement. The default is default. MapBasic reverts to the default behavior for a non-live access table instead of throwing an error.. which is to get the default styles from the MapCatalog (FromMapCatalog ON). 67 . All rights reserved. Frame defaults used in the Create Cartographic Legend statement have no affect on frames created in this statement. They have no affect on existing frames. This requires the workspace to bumped up to 800. Alter Cartographic Frame statement. Instead.e. unless the style clause contains text). ] | From source_table Set To expression [ Where { dest_column = source_column | Within | Contains | Intersects } ] [ Dynamic ] } table is the name of the table to which a column will be added. When you save to a workspace.

To add a permanent column to a table. Both tables must already be open. Filling The New Column With Explicit Values Using the Values clause. Dynamic specifies a dynamic (hot) computed column that can be automatically update: if you include this keyword. Float. 68 © 2006 MapInfo Corporation. Open Table "wards" Add Column wards(percent_dem) Values 31. SmallInt. MapInfo Professional joins the two tables.22. and it can include aggregate functions. and if you save a workspace while the temporary column is in use. For example.Add Column statement datatype is the data type of the column. include the optional Where clause. When you use a From clause. The values for the new column are explicitly specified.32. However. A Where clause of the form Where column = column joins the two tables by matching column values from the two tables. you are adding a column to the States table. MapInfo Professional automatically tries to join the two tables using the most suitable method. if you specify the clause Where Contains. Decimal(width.41..g. defined as Char(width). source_column is the name of a column from the source_table. type defaults to Float. If you omit the Where clause. MapBasic derives the values for the new column from a separate table (source_table). then subsequent changes made to the source table are automatically applied to the destination table. To specify how the two tables are joined. MapInfo Professional constructs a join by testing whether objects from the source_table contain objects from the table that is being modified. decimal_places).24. this expression usually extracts data from the source_table.35.66. source_table is the name of a second open table. This method is appropriate if a column from one of your tables has values matching a column from the other table (e. and your other table also has a column containing state names).88 Filling The New Column With Values From Another Table If you specify a From clause instead of a Values clause. you can specify a comma-separated list of explicit values to store in the new column. dest_column is the name of a column from the destination table (table). All rights reserved. the Where clause can specify a geographic join. the workspace will include information about the temporary column. Integer. through the Value clause. if the temporary column is based on base tables. use the Alter Table statement and Update statement. MapBasic 8.17. If both tables contain map objects. expression is the expression used to calculate values to store in the new column. The new column will not be permanently saved to disk. if not specified. The following example adds a temporary column to a table of “ward” regions.47. so that the temporary column will be rebuilt if the workspace is reloaded. Date or Logical.5 . Description The Add Column statement creates a temporary new column for an existing MapInfo Professional table.

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. All rights reserved.. and the secondary table represents objects that contain the points. Open Table "states" Interactive Open Table "city_1k" Interactive Add Column states(num_cities) From city_1k 'derive values from other table Set To Count(*)'count cities in each state Where Within 'join: where cities fall within states The Set To clause in this example specifies an aggregate function. Max( col ) Reference Guide © 2006 MapInfo Corporation. Function Avg( col ) Count( * ) Value Stored In The New Column Average of values from rows in the source table. specify a Set To clause that includes an aggregate function. MapBasic ignores the Dynamic clause. The following example adds a temporary column to the States table. Count(*). Filling The New Column With Aggregate Data If you specify a From clause. you can calculate values for the new column by aggregating data from the second table. Number of rows in the source table that correspond to the row in the table being updated. 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. When updating an existing column. omit the datatype parameter and specify a From clause instead of a Values clause. Aggregate functions are described below. The new column values are derived from a second table (City_1K..S. a table of major U. 69 . The new column will contain county names. Filling An Existing Column With Values From Another Table To update an existing column instead of adding a new column. Largest of the values from rows in the source table. After the completion of the Add Column statement. To perform data aggregation. The following table lists the available aggregate functions. each row in the States table will contain a count of how many major cities are in that state.Add Column statement The following example adds a “County” column to a “Stores” table. cities).

etc. Suppose you have a Towns table. Average calculation that makes adjustments based on how much of an object is within another object. Proportion Avg. Sum calculation that makes adjustments based on how much of an object is within another object. The object in the Risk table represents some sort of area that is at risk. which contains a region object. You also have a Risk table. Weighted average of the values from the source table.. you will consider half of that town's population to be at risk. perhaps the region object represents an area in danger of flooding due to proximity to a river.g. then stores the calculation in a new column (population_at_risk): Add Column Risk(population_at_risk Integer) From towns 70 © 2006 MapInfo Corporation. if a third of a town's area falls within the risk region. If half of a town's area falls within the risk region. MapBasic 8. population) about each town. 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. The last three functions (Proportion Sum. Weighted average calculation that makes adjustments based on how much of an object is within another object. All rights reserved. you will consider a third of that town's population to be at risk. Proportion Avg( col ) Proportion Sum( col ) Proportion WtAvg( col . weight_col ) Value Stored In The New Column Smallest of the values from rows in the source table. Given these two tables. The following example calculates the population at risk by using the Proportion Sum aggregate function.Add Column statement Function Min( col ) Sum( col ) WtAvg( col. containing town boundary regions and demographic information (e. weight_col ) Most of the aggregate functions operate on data values only. Sum of the values from rows in the source table.5 . you might want to calculate the population that lives within the risk region. This is best illustrated by example. Proportion WtAvg) perform calculations that take geographic relationships into account.

work with smaller region objects (e. For example. MapInfo Professional multiplies that number by the town's median_age value. Continuing the previous example. To ensure accurate results.. MapInfo Professional adds some or all of the town's town_pop value to a running total. MapInfo Professional adds half of the region's population to the total. and adds the result to a running total. If you use Proportion Sum in cases where the data values are not evenly distributed. Reference Guide © 2006 MapInfo Corporation. All rights reserved. however. and if the town region covers 10% of the risk region. MapInfo Professional adds 5 (five) to the running total.Add Column statement Set To Proportion Sum(town_pop) Where Intersects For each town that is at least partly within the risk region.g. that calculation produces a number between zero and one. because a very large percentage of the population lives in New York City. Dynamic Columns If you include the optional Dynamic keyword. MapInfo Professional treats each object as if it were completely inside or completely outside of the destination region (depending on whether the non-region object's centroid is inside or outside of the destination region). The Proportion Sum function produces results based on an assumption—the assumption that the number being totalled is distributed evenly throughout the region. suppose the Towns table contains a column. when the source table contains non-region objects. that indicates the median age in each town. the new column becomes a dynamic computed column. Thus. the results may not be realistic. if a town has a median_age value of 50. Proportion WtAvg is similar to Proportion Avg. the population of New York State is not evenly distributed. If you use Proportion Sum to process population statistics. The Proportion Avg aggregate function performs an average calculation which takes into account the percentage of an object that is covered by another object. operate on county regions instead of state regions). Using Proportion… Functions With Non-Region Objects When you use Proportion functions and the source table contains region objects. but it also lets you specify a data column for weighting the average calculation. median_age. an area representing half of a region does not necessarily contain half of the region's population. meaning that subsequent changes made to the source table are automatically applied to the destination table. and half of a region falls within another region. MapInfo Professional calculates percentages based on the overlap of regions. In reality. inclusive. 71 . MapInfo Professional calculates the percentage of the risk region that is covered by the town. the weighting is also proportionate. because 10% of 50 is 5. The following statement calculates the median age within the risk zone: Add Column Risk(age Float) From Towns Set To Proportion Avg(median_age) Where Intersects For each row in the Towns table. However.

and the map does not already contain any raster map layers. you can obtain a window identifier by calling the FrontWindow( ) function and WindowID( ) function. the map adopts the coordinate system and projection of the raster image. the window dynamically changes its projection. ] [ Animate ] window_id is the window identifier of a Map window. See Also Alter Table statement... MapInfo Professional then automatically redraws the Map window. in other words. Adding Layers of Different Projections If the layer added is a raster table. 72 © 2006 MapInfo Corporation.5 . the column values are frozen (the column is no longer updated dynamically). The window_id parameter is an integer window identifier representing an open Map window.Add Map statement If you create a dynamic column. the new table layer will be drawn last. when the map is redrawn. table . and you close either of the maps used for the geographic join. and then close the source table used to calculate the dynamic column. the specified table becomes the topmost layer in the window. if a geographic join is used in the creation of a dynamic column. while a map of point objects would be placed on top. A raster table or a map of region objects would be placed closer to the bottom of the map. If you include the optional Auto keyword. table is the name of a mappable open table to add to a Map window. the statement affects the topmost Map window. Similarly. All rights reserved. You can then use the Set Map statement to alter the order of layers in the Map window. If a Map window contains two or more raster layers. Update statement Add Map statement Purpose Adds another layer to a Map window. If the Add Map statement does not specify a window_id value. the column values are frozen. MapInfo Professional tries to automatically position the map layer at an appropriate place in the set of layers. Description The Add Map statement adds one or more open tables to a Map window. If you omit the Auto keyword. Syntax Add Map [ Window window_id ] [ Auto ] Layer table [ . depending on which image occupies more of the window at the time. MapBasic 8. unless you have suppressed redraws through a Set Event Processing Off statement or Set Map…Redraw Off statement.

MB. where map features are updated frequently. where map objects are constantly changing. Also. the first layer named becomes the animation layer. The following example opens a table (Vehicles) and makes the table an animation layer: Open Table "vehicles" Interactive Add Map Layer vehicles Animate If the Add Map statement specifies two or more layers and it includes the Animate keyword. You can receive current vehicle coordinates by using GPS (Global Positioning Satellite) technology. For example. 73 . the added layer becomes a special layer known as the animation layer. and the remaining layers are added to the map as conventional layers. MapInfo Professional converts the table coordinates “on the fly” so that the entire Map window appears in the same projection. When a table's native projection differs from the projection of the Map window. the map redraws much more quickly if the objects being updated are stored in the animation layer instead of a conventional layer. To terminate the animation layer processing. In this type of application. Using Animation Layers to Speed Up Map Redraws If the Add Map statement includes the Animate keyword. Note: When MapInfo Professional converts map layers in this fashion. Animation layers have special restrictions. issue a Remove Map…Layer Animate statement. because MapInfo Professional only redraws the one animation layer. users cannot use the Info tool to click on objects in an animation layer. For an example of animation layers. see the MapBasic User's Guide. All rights reserved. When an object in the animation layer is moved. map redraws take longer. and then update the point objects to show the current vehicle locations on the map. For more information about animation layers. leads See Also Map statement. Remove Map statement. MapInfo Professional continues to display the Map window using whatever coordinate system and projection were used before the Add Map statement. you can develop a fleet-management application that represents each vehicle as a point object. Set Map statement Reference Guide © 2006 MapInfo Corporation. Example Open Table "world" Map From world Open Table "cust1992" As customers Open Table "lead1992" As leads Add Map Auto Layer customers. even if the table specified is stored with a different native projection or coordinate system. The animation layer is useful in real-time applications. since MapInfo Professional must perform mathematical transformations while drawing the map. each Map window can have only one animation layer.Add Map statement If the layer added is not a raster table. the Map window redraws very quickly. For example. see the sample program ANIMATOR.

such as the following: Run Menu Command M_TOOLS_RULER To make a custom tool the active tool..g. MapInfo Professional modifies all buttons that call that handler. For example.g. Similarly. M_TOOLS_RULER or M_WINDOW_LEGEND) from MENU. The Enable keyword enables a button that was previously disabled. checking the Show/Hide Statistics button does not actually show the Statistics window—it only affects the appearance of the button. the following statement selects the Show Statistics Window button: Alter Button M_WINDOW_STATISTICS Check Note: Checking or unchecking a standard MapInfo Professional button does not automatically invoke that button's action. it only changes the appearance of the button.DEF. the appropriate statement is the Open Window Statistics. and the Uncheck keyword has the effect of releasing the button. All rights reserved.5 . issue the appropriate statement. 74 © 2006 MapInfo Corporation. The Check keyword has the effect of “pushing in” a ToggleButton control. or deselects a button from a ButtonPad (toolbar). The Check and Uncheck keywords select and deselect ToggleButton type buttons. selects. such as the Show Statistics Window button. or a standard command code (e. you can use the Check keyword to change the appearance of a ToolButton. To make a standard tool the active tool. The handler can be the name of a MapBasic procedure. button_id is a unique integer button identification number. If the statement specifies a button_id number. To invoke an action as if the user had checked or unchecked the button. MapBasic 8. in this example. a procedure name). Syntax Alter Button { handler | ID button_id } [ { Enable | Disable } ] [ { Check | Uncheck } ] handler is the handler that is already assigned to an existing button. thus. so that the user cannot select the button. issue a Run Menu Command statement. MapInfo Professional modifies only the button that has that ID. disables. However. use the syntax Run Menu Command ID IDnum. checking a ToolButton does not actually select that tool..Alter Button statement Alter Button statement Purpose Enables. Description If the Alter Button statement specifies a handler (e. The Disable keyword changes the button to a grayed-out state.

g. and 0. 3 for Tools. visible when toolbar is floating. or it can have the following syntax: { PushButton | ToggleButton | ToolButton } Calling { procedure | menu_code | OLE methodname | DDE server. ] ] [ Title new_title ] [ Width w ] [ Position ( x. 75 . handler_num is an integer handler code (e. or adds / removes buttons. ..g..g. “in” for inches. column ) ] [ { Show | Hide } ] [ { Fixed | Float } ] [ Destroy ] current_title is the toolbar's title string (e. Create ButtonPad statement. y ) [ Units unit_name ] ] [ ToolbarPosition ( row. “Main”). new_title is a string that becomes the toolbar's new title. row.... 1 represents the second toolbar on the top row). Each button_definition clause can consist of the keyword Separator.. 0 places the pad at the left edge of the top row of toolbars. 2 for Drawing. ] ] [ Remove { handler_num | ID button_id } [ . 0. All rights reserved. inches). pad_num is the ID number for a standard toolbar: 1 for Main.g. unit_name is a string paper unit name (e. topic } [ ID button_id ] [ Icon icon_code [ File file_spec ] ] [ Cursor cursor_code [ File file_spec ] ] [ DrawMode dm_code ] [ HelpMsg msg ] [ ModifierKeys { On | Off } ] Reference Guide © 2006 MapInfo Corporation. Run Menu Command statement Alter ButtonPad statement Purpose Displays / hides a ButtonPad (toolbar).. 5 for ODBC. specified in paper units (e. in terms of the number of buttons across. column specify the toolbar's position when docked (e. 4 for Standard. x.. w is the pad width.. y specify the toolbar's position when floating.DEF. button_id is a custom button's unique identification number.g. “cm” for centimeters). M_TOOLS_RULER) from MENU. Syntax Alter ButtonPad { current_title | ID pad_num } [ Add button_definition [ button_definition .Alter ButtonPad statement See Also Alter ButtonPad statement.

If the File sub-clause specifies the name of a file containing icon resources. All rights reserved. The ModifierKeys clause applies only to ToolButtons. see example below. see Create ButtonPad statement on page 167. The first part of msg is the status bar help message. include the Fixed or the Float keyword. msg is a string that specifies the button's status bar help and. DM_CUSTOM_LINE) from ICONS. or as a parameter to be used with the Alter Button statement. For details on the Calling DDE clause syntax.. its position is controlled by the Position clause. Icon icon_code specifies the icon to appear on the button. MI_ICON_RULER). or destroy an existing ButtonPad. Default is Off (modifier keys have no effect). include the Destroy keyword. To show or hide a ButtonPad. see the MapBasic User Guide. To destroy a ButtonPad. ToolTip help..DEF. For details on the Calling OLE clause syntax. When a pad is floating. button_id specifies the unique button number. This number can be used: as a tag in help. cursor_code is an integer resource ID identifying a resource in the file. its position is controlled by the ToolbarPosition clause. Applies only to ToolButtons. methodname is a string specifying an OLE method name. or only click with the tool.DEF (e. If the File sub-clause specifies the name of a file containing icon resources. optionally. icon_code is an integer resource ID identifying a resource in the file.DEF. modify.Alter ButtonPad statement [ { Enable | Disable } ] [ { Check | Uncheck } ] procedure is the handler procedure to call when a button is used.. 76 © 2006 MapInfo Corporation. MapInfo Professional runs the menu command when the user uses the button. Description Use the Alter ButtonPad statement to show. dm_code specifies whether the user can click and drag. when a pad is docked.DEF (e. it no longer appears in the Options > Toolbars dialog box. menu_code is a standard MapInfo Professional menu code from MENU.g.g. dm_code is a code (e. icon_code can be one of the standard MapInfo icon codes listed in ICONS. Once a ButtonPad is destroyed. Cursor cursor_code specifies the shape the mouse cursor should adopt whenever the user chooses a ToolButton tool. as a parameter to allow the handler to determine which button is in use (in situations where different buttons call the same handler).g. see Create ButtonPad statement on page 167.5 ..g. For an introduction to ButtonPads. include the Show or Hide keyword. cursor_code is a code (e. hide. The user can also control whether the pad is docked or not by dragging the pad to or from the top of the screen. MapBasic 8. This clause applies only to ToolButtons. it controls whether the shift and control keys affect “rubber-band” drawing if the user drags the mouse while using a ToolButton. MI_CURSOR_ARROW) from ICONS. To set whether the pad is fixed to the top of the screen (“docked”) or floating like a window. server and topic are strings specifying a DDE server and topic name. The user also can show or hide ButtonPads by choosing the Options > Toolbars command. M_FILE_OPEN). If the msg string includes the letters \n then the text following the \n is used as the button's ToolTip help.

the button is disabled (grayed out) when it appears. a line connects the cursor with the location where the user clicked..DEF. the button is automatically selected (“checked”) when it first appears. To see a demonstration of these icons. such as Main and Drawing. which controls the appearance of the mouse cursor while the user is using the custom tool. Note: MapInfo Professional has many built-in icons that are not part of the normal user interface. and also lets you copy any icon's define code to the clipboard (so that you can then paste the code into your program).g. If the user clicks while using a custom ToolButton tool. then deselect by clicking again). For more information on creating Windows icons. The File file_spec sub-clause refers to a DLL file that contains bitmap resources. Available cursor codes are listed in ICONS. The following table lists the available drawing modes. MapInfo Professional automatically calls the tool's handler.g.g. which controls whether the user can drag with the tool (e. and then use for clicking on a Map or Layout window). the parameter n must refer to one of the icon codes listed in ICONS.. to draw a point). If you include the optional Disable keyword when adding a button. As the user drags. A ToolButton definition also can include a Cursor clause. Reference Guide © 2006 MapInfo Corporation. There are three types of button controls you can add: PushButton controls (which the user can click and release—for example. The procedure for specifying a custom cursor is similar to the procedure for specifying a custom icon. to display a dialog box). the procedure can call CommandInfo( ) to determine the ID of the button currently in use. MI_CURSOR_CROSSHAIR or MI_CURSOR_ARROW). Subsequent Alter Button statements can enable the button. unless the user cancels (e. to draw a line) or only click (e. This sample program displays icons. by pressing the Esc key while dragging the mouse). Custom Drawing Modes A ToolButton definition can include a DrawMode clause. A handler procedure can call CommandInfo( ) to determine where the user clicked. the n parameter refers to the ID of a bitmap resource. DrawMode parameter DM_CUSTOM_POINT DM_CUSTOM_LINE Description The user cannot drag while using the custom tool.. However.g.MBX. see the MapBasic User Guide.Alter ButtonPad statement The Alter ButtonPad statement can add buttons to existing ButtonPads.DEF (e.. and ToolButton controls (which the user can select. If two or more tools call the same handler procedure. if the button's handler is a standard MapInfo Professional command. ToggleButton controls (which the user can select by clicking. run the sample program ICONDEMO.. MI_ICON_RULER).g. If you omit the File clause. All rights reserved. MapInfo Professional automatically enables or disables the button depending on whether the command is currently enabled. 77 . Codes in the left column are defined in ICONS.DEF (e. Custom Icons and Cursors The Icon clause specifies the icon that appears on the button. If you include the optional Check keyword when adding a ToggleButton or a ToolButton.

5) Units "in" The sample program. The user may draw a polygon.0. use the function call: CommandInfo(CMD_INFO_CUSTOM_OBJ).0 (upper left): Alter ButtonPad "Main" Fixed ToolbarPosition(0. All rights reserved. an elliptical marquee appears. As the user drags. contains the following Alter ButtonPad statement. MapBasic 8. To disable autoscroll. To retrieve the object drawn by the user.5 . (Note that “ID 3" identifies the Tools ButtonPad. a circular marquee appears. a rectangular marquee appears. MapInfo Professional selects all objects (from selectable map layers) within the polygon.5. which allows the user to scroll a Map or Layout by clicking and dragging to the edge of the window. To retrieve the object drawn by the user. and sets its floating position to half an inch inside the upper-left corner of the screen. The polygon is not saved. use the function call: CommandInfo(CMD_INFO_CUSTOM_OBJ). see Set Window statement on page 611. ScaleBar. DM_CUSTOM_POLYGON DM_CUSTOM_POLYLINE All of the draw modes except for DM_CUSTOM_POINT support the Autoscroll feature. which adds a custom ToolButton to the Tools ButtonPad.) 78 © 2006 MapInfo Corporation. if you include the ModifierKeys clause.Alter ButtonPad statement DrawMode parameter DM_CUSTOM_RECT DM_CUSTOM_CIRCLE DM_CUSTOM_ELLIPSE Description As the user drags. As the user drags. Note: MapBasic supports an additional draw mode that is not available to MapInfo Professional users. the user can force the marquee to a circular shape by holding down the Shift key. The user may draw a polyline.0) The next example moves the Main ButtonPad so that it is floating instead of docked. Alter ButtonPad "Main" Float Position(0. If a custom ToolButton has the following Calling clause Calling M_TOOLS_SEARCH_POLYGON then the tool allows the user to draw a polygon. Examples The following example shows the Main ButtonPad and hides the Drawing ButtonPad: Alter ButtonPad "Main" Show Alter ButtonPad "Drawing" Hide The next example docks the Main ButtonPad and sets its docked position to 0. When the user double-clicks to close the polygon.

.. ] ] [ Border Pen. ] ] [ . 2. You cannot use a layer name. . | Symbol Symbol.. subtitle. Brush. frame_subtitle is a string which defines a frame subtitle.. Currently there is no MapBasic function to get information about the number of styles in a frame. Create ButtonPad statement. All rights reserved. y ) [ Units paper_units ] ] [ Title [ frame_title ] [ Font.. For example.. ] [ ID { id } Text { style_name } ] [Line Pen.) Syntax Alter Cartographic Frame [ Window legend_window_id ] Id { frame_id } [ Position ( x. (To change the size. three frames on a legend would have the successive ID's 1.... use the Set Window statement. title. ] ] [ SubTitle [ frame_subtitle ] [ Font.... and 3.Set Window statement Alter Cartographic Frame statement Purpose The Alter Cartographic Frame statement changes a frame(s) position. Reference Guide © 2006 MapInfo Corporation.. frame_title is a string which defines a frame title. ] legend_window_id is an integer window identifier which you can obtain by calling the FrontWindow( ) function and WindowID( ) function. | Region Pen.. frame_id is the ID of the frame on the legend. position or title of the legend window. ButtonPadInfo( ) function... id is the position within the style list for that frame.. 79 .Alter Cartographic Frame statement 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 button. ] [ Style [ Font.. border and style of an existing cartographic legend created with the Create Cartographic Legend statement. See Also Alter Button statement.

You can only update the Style type for a custom style. The Position clause controls the frame's position on the legend window. which defaults to inches.Alter Control statement style_name is a string that displays next to each symbol for the frame specified in ID. The Title and SubTitle clauses accept new text. Set Cartographic Legend statement. MapBasic has a current paper units setting. The Style clause must contain a list of definitions for the styles displayed in frame. title is a string representing the new title to assign to the control. There is no way to add or remove styles from any type of frame. The upper left corner of the legend window has the position 0. and PopupMenu controls. See Also Create Cartographic Legend statement. Remove Cartographic Frame statement Alter Control statement Purpose Changes the status of a control in the active custom dialog box. 0. The “%” character will be replaced by the text “Line”. For example. Add Cartographic Frame statement. used to reset the contents of ListBox. array_name is the name of an array variable.5 . Syntax Alter Control id_num [ Title { title | From Variable array_name } ] [ Value value ] [ { Enable | Disable } ] [ { Show | Hide } ] [ Active ] id_num is an integer identifying one of the controls in the active dialog box.tab layer. Restrictions You cannot issue this statement through the MapBasic window. “Point. “% of #” will expand to “Region of States” for the frame corresponding to the states. An Alter Cartographic Frame statement can override the current paper units by including the optional Units subclause within the Position clause. You can update the Text of any style. Description If a Window clause is not specified MapInfo Professional will use the topmost legend window. All rights reserved. Position values use paper units settings. such as “in” (inches) or “cm” (centimeters). 80 © 2006 MapInfo Corporation. “Region”. MapBasic 8. MultiListBox. as appropriate for the symbol. The “#” character will be replaced with the layer name. a MapBasic program can change this setting through the Set Paper Units statement. new font or both. value is the new value to associate with the specified control.

and a Cancel button. Value. Some attributes do not apply to all types of controls. If the control is a ListBox. To add a list item to the set of selected MultiListBox items. For example. The Title clause resets the text that appears on most controls (except for Picker controls and EditText controls. Enable/Disable. you may want to pad it with spaces when you first define it.. The id_num specifies which dialog box control should be modified. Therefore.def" Declare Sub Main Declare Sub checker Sub Main Dim browse_it.e. Use the Hide and Show keywords to make controls disappear or reappear. An Alter Control…Active statement puts the keyboard focus on the specified EditText control. thus. or PopupMenu control. a single Alter Control statement could change the name. your Dialog statement could include the following clause: Control StaticText ID 1 Title "Message goes here" + Space$(30) Example The following example creates a dialog box containing two checkboxes. an OK button. accordingly. However. MapInfo Professional cannot increase the size of the StaticText control after it is created. map_it As Logical Dialog Reference Guide © 2006 MapInfo Corporation. the Alter Control statement should only be issued while a dialog box is active (i. To de-select all items in a MultiListBox control. Hide/Show. a Button control may be enabled or disabled. If there are two or more nested dialog boxes on the screen. You can use an Alter Control statement to modify the text that appears in a StaticText control. the Alter Control statement only affects controls within the topmost dialog box. from within a handler procedure that is called by one of the dialog box controls).Alter Control statement Description The Alter Control statement modifies one or more attributes of a control in the active dialog box. Note: In this case. The Active keyword applies only to EditText controls. Initially. but has no value attribute. the OK button is disabled (grayed out). All rights reserved. do not issue the Alter Control statement from within the MultiListBox control's handler. MultiListBox. and the enabled/disabled status of a dialog box control. the Title clause can read the control's new contents from an array of string variables. to reset the contents of an EditText control. Note that all of these clauses can be included in a single statement. Active) modifies a different attribute of a dialog box control. Include "mapbasic. issue an Alter Control statement with a positive integer value corresponding to the number of the list item. if you plan to alter the length of a StaticText control. by specifying a From Variable clause. this corresponds to the id_num parameter specified within the ID clause of the Dialog statement. use a value setting of zero. Each of the optional clauses (Title. set its Value). the value. For example. 81 . The OK button is only enabled if the user selects one or both of the check boxes.

82 © 2006 MapInfo Corporation. ' enable the OK button..Alter MapInfoDialog statement 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 ' . Dialog Preserve statement. otherwise.. or assigns new values to controls in MapInfo Professional's standard dialog boxes. End If End Sub Sub checker ' If either check box is checked. Use this statement with caution. All rights reserved.5 . As a result. MapBasic programs that use this statement may not work correctly when run using future versions of MapInfo Professional. If ReadControlValue(1) Or ReadControlValue(2) Then Alter Control 3 Enable Else Alter Control 3 Disable End If End Sub See Also Dialog statement. Disable it. MapBasic 8.. ReadControlValue( ) function Alter MapInfoDialog statement Purpose Disables. hides. Restrictions CAUTION: The Alter MapInfoDialog statement may not be supported in future versions of MapInfo Professional.. then the user clicked OK.

For example. MapInfo Professional displays the ID number of the current dialog box. indicating which control to modify. MapInfo Professional will not perform the Find operation unless you display the dialog box and the user clicks OK. Reference Guide © 2006 MapInfo Corporation. etc. To determine the ID number for a specific control. but because you used the -helpdiag argument. The MapBasic software does not provide a Spy++ utility. Determining ID Numbers To determine a dialog box's ID number. For example. Description Use this statement if you need to disable. hide. Note: There are different “common dialog boxes” (such as the Open and Save dialog boxes) for different versions of Windows.—in MapInfo Professional's standard dialog boxes. however. you may need to issue two Alter MapInfoDialog statements. check boxes. Although the Alter MapInfoDialog statement changes the initial appearance of a dialog box. or assign new values to controls—buttons. } ] [ Control. ne for each version of the common dialog box. Each individual control has an ID number. and most Cancel buttons have an ID number of 2. use the Alter Control statement..exe -helpdiag After you run MapInfo Professional with the -helpdiag argument. you can use Alter MapInfoDialog to store an address in the Find dialog box. To modify custom dialog boxes that you create using the Dialog statement. the changes do not have any effect unless the user clicks OK. you must use a third-party developer's utility. run MapInfo Professional with this command line: mapinfow. the Help button launches Help. 83 .. and if your application will be used under different versions of Windows. Note: Use this statement to modify only MapInfo Professional's standard dialog boxes.. Ordinarily. new_value is a new value assigned to the dialog box control. such as the Spy++ utility that Microsoft provides with its C compiler. All rights reserved. indicating which MapInfo Professional dialog box to alter. most OK buttons have an ID number of 1. { Disable. display a MapInfo Professional dialog box and click the Help button. 1 or larger.. control_ID is an integer ID number. If you want to modify a common dialog box.Alter MapInfoDialog statement Syntax 1 (assigning non-default settings) Alter MapInfoDialog dialog_ID Control control_ID { Disable | Hide | Value new_value } [ . ] Syntax 2 (restoring default settings) Alter MapInfoDialog dialog_ID Default dialog_ID is an integer ID number.

All ID numbers are subject to change in future versions of MapInfo Professional.”) in the first edit box and hiding the Respecify button. use the return value from the MakeSymbol( ) function). edit box. Use the Value clause to change the setting of the control. When you alter common dialog boxes (e. Symbol style button: You may assign a new symbol style (e. If SystemInfo(SYS_INFO_MIVERSION) = 400 Then Alter MapInfoDialog 2202 Control 5 Value "23 Main St. editable combo box: You may assign new text by using a text string in the new_value parameter. or you may assign new text to static text. static text." Control 12 Hide End If Run Menu Command M_ANALYZE_FIND The ID number 2202 refers to the Find dialog box. or specify a Brush value to reset the Brush style.5 . button. (For an example of this type of control. this example calls the SystemInfo( ) function to determine the MapInfo Professional version number. Checkbox: You may set the checkbox (specify a value of 1) or clear it (value of zero).. The Portrait and Landscape buttons are 1056 and 1057. which appears when you double-click an editable region. the Open dialog box). When you alter other MapInfo Professional dialog boxes..Alter MapInfoDialog statement Types of Changes Allowed Use the Disable keyword to disable (gray out) the control. List box. Radio button: Setting a button's value to 1 selects that button from the radio group. See Also Alter Control statement. respectively. Dialog statement.g. Control 12 is the Respecify button. see MapInfo Professional's Region Style dialog box. you may reset the item selected in a combo box control. the following list summarizes the types of changes you may make. therefore. combo box: You may set which item is selected by using a numeric new_value. All rights reserved. Font style button: You may assign a new Font value.g. and edit box controls. Control 5 is the edit box where the user types an address. • • • • • • • • • Button. Combined Pen/Brush style button: Specify a Pen value to reset the Pen style.) Example The following example alters MapInfo Professional's Find dialog box by storing a text string (“23 Main St. Use the Hide keyword to make the control disappear. Brush style button: You may assign a new Brush value. MapBasic 8. You can change the orientation control in the Page Setup dialog box. which this example hides. Pen style button: You may assign a new Pen value. SystemInfo( ) function 84 © 2006 MapInfo Corporation.

menu_id is an integer menu ID from 1 to 22. Syntax 2 Alter Menu { menuname | ID menu_id } Remove { handler | submenuname | ID menu_item_id } [ .. handler is either the name of a sub procedure or the code for a standard MapInfo Professional command. 85 .Alter Menu statement Alter Menu statement Purpose Adds or removes items from an existing menu. 1 represents the File menu. Syntax 1 Alter Menu { menuname | ID menu_id } Add menudef [ .. { handler | submenuname | ID menu_item_id } . menudef. menu_item_id is a custom integer menu item identifier. “File”). menu_id is a standard integer menu ID from 1 to 22..g. the name of an item to add to the specified menu. according to the syntax: newmenuitem [ ID menu_item_id ] [ HelpMsg help ] [ { Calling handler | As menuname } ] menuname is the name of an existing menu (e. If you specify a command code for a standard MapInfo Professional Show/Hide command (such as M_WINDOW_STATISTICS). All rights reserved. or a special syntax for handling the menu event by calling OLE or DDE. ] menuname is the name of an existing menu. newmenuitem is a string. submenuname is the name of a hierarchical submenu to remove from the specified menu... which can be used in subsequent Alter Menu Item statements. ] Where each menudef defines a menu item. 1 represents the File menu.g. Reference Guide © 2006 MapInfo Corporation. menu_item_id is a custom integer menu item identifier. see the Create Menu statement.. help is a string that will appear on the status bar while the menu item is highlighted. or a code for a standard menu command (e. For more details on the different types of handler syntax. to preserve the item's Show/Hide behavior. handler is the name of a procedure. the newmenuitem string must start with an exclamation point and include a caret (^). M_FILE_NEW).

Available when a Layout window is active. the Alter Menu statement must specify the translated version of the menu name. Objects menu.g. MapBasic 8. this menu is only available when a Map window is active. Window menu. Edit menu.Alter Menu statement Description The Alter Menu statement adds menu items to an existing menu or removes menu items from an existing menu. Browse menu. Map menu. Redistrict menu. the Alter Menu statement can identify which menu to alter by using the ID clause. Graph menu. and the menu names have been translated. Layout menu. Note that if the application is running on a non-English language version of MapInfo. All rights reserved. Ordinarily.. The ID clause identifies the menu by a number from 1 to 31. this only appears when a Browser window is the active window. If the menu to be modified is one of the standard MapInfo Professional menus. Tools menu. Ordinarily. The following table lists the names and ID numbers of all standard MapInfo Professional menus. Options menu. ID Numbers for Menus Menu Name File Edit Query Tools Options Window Help Browse 1 2 3 4 5 6 7 8 ID File menu. The statement can identify the menu to be modified by specifying the name of the menu (e. “File”) through the menuname parameter. Table menu. Note: Menus 16 through 31 are shortcut menus. Description Map 9 Layout Graph MapBasic 10 11 12 Redistrict Objects Table 13 14 15 86 . Available when a Graph window is active. Available when the MapBasic window is active. which appear if the user clicks with the right mouse button.5 © 2006 MapInfo Corporation. MapBasic menu. Query menu. Help menu. Available when a Districts Browser is active.

3D Window menu. The Map window shortcut menu. The ID number (300) can be used in subsequent Alter Menu Item statements. MapperShortcut BrowserShortcut LayoutShortcut GrapherShortcut (1) 17 18 19 20 CmdShortcut RedistrictShortcut 21 22 LegendShortcut GrapherShortcut (2) 23 24 3DMapShortcut 3DWindow Graph Legend 25 28 29 31 Examples The following statement adds an item to the File menu. Graph menu. Alter Menu ID 1 Add "Special" ID 300 Calling sub_procedure_name Reference Guide © 2006 MapInfo Corporation. The Browse window shortcut menu. The Redistricting shortcut menu. This menu contains options for creating graphs. All rights reserved. Alter Menu "File" Add "Special" Calling sub_procedure_name In the following example. The graph window shortcut menu. 87 . the menu to be modified is identified by its number. The MapBasic window shortcut menu. The Legend window shortcut menu. This menu contains options for formatting graphs already created.Alter Menu statement ID Numbers for Menus (continued) Menu Name DefaultShortcut 16 ID Description The default shortcut menu. Legend menu. The Graph window shortcut menu. Alter Menu ID 1 Add "Special" Calling sub_procedure_name In the following example. The Layout window shortcut menu. This menu appears if the user right-clicks on a window that does not have its own shortcut menu defined. the menu item that is added contains an ID clause. available when the Districts Browser is active. The 3D Map window shortcut menu.

.g. The menuname parameter is a string representing the name of a menu.Alter Menu Bar statement The following example removes the custom item from the File menu. uses a Create Menu statement to create a menu called “TextBox. TextBox. However. Alter Menu Item statement. and if the menu names have been translated. each of MapInfo Professional's standard menus (File. { menuname | ID menu_id } . ] menuname is the name of an available menu (e. 88 © 2006 MapInfo Corporation. Description The Alter Menu Bar statement adds or removes one or more menus from the current menu bar. MapBasic 8.5 . Create Menu statement.” and then issues the following Alter Menu statement to add the TextBox menu as a hierarchical menu located on the Tools menu: Alter Menu "Tools" Add "(-". such as “File” or “Edit”. "TextBox" As "TextBox" The following example adds a custom command to the Map window's shortcut menu (the menu that appears when an MapInfo Professional user right-clicks on a Map window). 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. Alter Menu ID 17 Add "Find Nearest Site" Calling sub_procedure_name See Also Alter Menu Bar statement. Create Menu Bar statement Alter Menu Bar statement Purpose Adds or removes menus from the menu bar.. “File”) menu_id is a standard menu ID from one to fifteen. one represents the File menu. Alter Menu ID 1 Remove sub_procedure_name The sample program.. All rights reserved. Syntax Alter Menu Bar { Add | Remove } { menuname | ID menu_id } [ . the Alter Menu Bar statement must specify the translated version of the menu name.

the menu remains part of the “pool” of available menus. etc.) also has a menu ID. Example The following example creates a custom menu. Adding Menus to the Menu Bar An Alter Menu Bar Add statement adds a menu to the right end of the menu bar. and then add the Query menu back onto the menu bar (at the right end of the bar). "Delete" Calling delsub 'Remove the Window menu and Help menu Alter Menu Bar Remove ID 6.Alter Menu Bar statement Edit. which you can use regardless of whether the menu names have been translated. then uses an Alter Menu Bar Add statement to add the DataEntry menu to MapInfo Professional's menu bar. the following pair of statements would first remove the Query menu from the menu bar. MapInfo Professional would ignore any Ctrl-O key-presses. ID 6. MapInfo Professional ignores any hotkey sequences corresponding to items that were on the removed menu. Removing Menus from the Menu Bar An Alter Menu Bar Remove… statement removes a menu from the menu bar. called DataEntry. For example. For example. if an Alter Menu Bar Remove statement removed the File menu. However. Declare Sub addsub Declare Sub editsub Declare Sub delsub Create Menu "DataEntry" As "Add" Calling addsub. All rights reserved. For a list of MapInfo Professional's standard menu names and their corresponding ID numbers. Thus. specifying ID 2 always refers to the Edit menu. 89 . a MapInfo Professional user might ordinarily press Ctrl-O to bring up the File menu's Open dialog box. ID 7 'Add the custom menu. If you need to insert a menu at another position on the menu bar. regardless of whether the menu has been translated. If you add enough menus to the menu bar. see Alter Menu statement on page 85. then the Window & Help menus Alter Menu Bar Add "DataEntry". use the Create Menu Bar statement to redefine the entire menu bar. the menu bar wraps down onto a second line of menu names. "Edit" Calling editsub. Alter Menu Bar Remove "Query" Alter Menu Bar Add "Query" After an Alter Menu Bar Remove… statement removes a menu. however. ID 7 Reference Guide © 2006 MapInfo Corporation.

Note that it is possible for multiple. the name of a procedure in the same program). Create Menu statement. menu_item_id is an integer that identifies a menu item. or an ID clause to indicate which menu item(s) to modify. For example. MapInfo Professional alters only the menu item that was defined with that ID. this corresponds to the menu_item_id parameter specified in the statement that created the menu item (Create Menu statement or Alter Menu statement). All rights reserved. If the statement includes an ID clause.Alter Menu Item statement Before adding the custom menu to the menu bar. MapInfo Professional alters all menu items that call that handler. Menu Bar statement Alter Menu Item statement Purpose Alters the status of a specific menu item. 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. separate menu items to call the same handler procedure.g. If the Alter Menu Item statement includes the name of a handler procedure. and the Help menu to the menu bar. Create Menu Bar statement. A MapBasic application cannot refer to menu item IDs created by other MapBasic applications. Syntax Alter Menu Item { handler | ID menu_item_id } { [ Check | Uncheck ] | [ Enable | Disable ] | [ Text itemname ] | [ Calling handler | As menuname ] } handler is either the name of a Sub procedure or the code for a standard MapInfo Professional command. menuname is the name of an existing menu. The statement must either specify a handler (e. Description The Alter Menu Item statement alters one or more of the items that make up the available menus. the Window menu. MapBasic 8. this program removes the Help menu (menu ID 7) and the Window menu (ID 6) from the menu bar. you could use the Alter Menu Item statement to check or disable (gray out) a menu item. 90 © 2006 MapInfo Corporation.5 . This technique guarantees that the last two menus will always be Window and Help. The program then adds the custom menu. Alter Menu Item statement. itemname is the new text for the menu item (may contain embedded codes). See Also Alter Menu statement..

For example. although you can treat specific tools as menu items (by referencing defines from MENU. the File > Close command is disabled whenever there are no tables open. Alter Menu Bar statement. MapBasic applications should not attempt to enable or disable standard MapInfo Professional menu items. Alter Menu Item delsub Disable See Also Alter Menu statement. The Disable clause and the Enable clause control whether the item is disabled (grayed out) or enabled. Note that a menu item may only be checked if it was defined as “checkable” (i. If the user chooses the menu item. 91 .e. Note that MapInfo Professional automatically enables and disables various menu items based on the current circumstances. All rights reserved. The Calling clause specifies a handler for the menu item. Create Menu statement Reference Guide © 2006 MapInfo Corporation. "Delete All" ID 101 Calling delsub 'Remove the Help menu Alter Menu Bar Remove ID 7 'Add both the new menu and the Help menu Alter Menu Bar Add "DataEntry" .DEF. "Delete" ID 100 Calling delsub. if the Create Map statement included a “!” as the first character of the menu item name).Alter Menu Item statement The Check clause and the Uncheck clause affect whether the item appears with a checkmark on the menu. Examples The following example creates a custom “DataEntry” menu. "Edit" Calling editsub. Declare Sub addsub Declare Sub editsub Declare Sub delsub Create Menu "DataEntry" As "Add" Calling addsub. such as M_TOOLS_RULER). Therefore. which is the handler for both menu items. Similarly. you should not attempt to enable or disable tools through the Alter Menu Item statement. because it identifies the handler procedure delsub. Alter Menu Item ID 101 Disable The following statement disables both the “Delete” and the “Delete All” items. MapInfo Professional calls the item's handler. ID 7 The following Alter Menu Item statement renames the “Edit” item to read “Edit…” Alter Menu Item editsub Text "Edit…" The following statement disables the “Delete All” menu item. The Text clause allows you to rename a menu item.

g. removes. Description The Alter Object statement alters the shape. new_geo_value | Node { Add [ Position polygon_num. y are x.g.g. node_num } } obj is an object variable. the x. MapBasic alters a geographical attribute for objects other than polylines and regions (e. The effect of an Alter Object statement depends on whether the statement includes an Info clause.g.. object_info_code is an integer code relating to the ObjectInfo( ) function (e. position. x.5 . If the statement includes a Node clause. polygon_num is a integer value (one or larger).or y-coordinate of a point object). MapBasic adds. the object's Pen and Brush styles).. node_num ( x . If the statement includes a Geography clause. MapBasic alters the object's graphical style (e. OBJ_GEO_POINTX). node_num is a integer value (one or larger). If the statement includes an Info clause.. position. y ) | Remove Position polygon_num. object_geo_code is an integer code relating to the ObjectGeography( ) function (e. 92 © 2006 MapInfo Corporation. new_info_value | Geography object_geo_code .and y-coordinates of a node. Syntax Alter Object obj { Info object_info_code.. or repositions a node (this applies only to polyline or region objects).Alter Object statement Alter Object statement Purpose Modifies the shape. the new x-coordinate).. or graphical style of an object.g. OBJ_INFO_PEN).. y ) | Set Position polygon_num. a Node clause. identifying one polygon from a region object or one section from a polyline object. node_num ] ( x. identifying one node from a polyline or polygon. or graphical style of an object. MapBasic 8. new_info_value specifies the new object_info_code attribute to apply (e. a new Pen style).g. All rights reserved. or a Geography clause. new_geo_value specifies the new object_geo_code value to apply (e.

or 2. obj_info_code Value OBJ_INFO_PEN Result of Alter Object Resets object's Pen style. Resets a Text object's Font style. new_info_value must be a Font expression. new_info_value must be an integer window ID. the Pen or Brush). you can reset an object's style (e. Resets a Polyline object's smoothed/unsmoothed setting. new_info_value must be a Pen expression.DEF. Resets a Point object's Symbol style. 93 . Changes a Text object's line spacing. Note that the obj_info_code values are defined in the standard MapBasic definitions file. new_info_value must be a logical expression. new_info_value must be a string. Resets object's Brush style. Changes which window is displayed in a Layout frame. b_fillstyle Note that you use the same code (e. new_info_value must be a float value of 1. you can determine an object's current Brush style by calling the ObjectInfo( ) function: Dim b_fillstyle As Brush b_fillstyle = ObjectInfo(Selection. Changes the text string that comprises a Text object.Alter Object statement Info clause By issuing an Alter Object statement with an Info clause. The Info clause lets you modify the same style attributes that you can query through the ObjectInfo( ) function. For example. your program should Include “MAPBASIC. the following Alter Object statement allows you to reset the Brush style: Alter Object obj_variable_name Info OBJ_INFO_BRUSH.g.. OBJ_INFO_BRUSH) Conversely.5. Accordingly.DEF” if you intend to use the Alter Object…Info statement. Changes the title of a Frame object. new_info_value must be a Symbol expression. All rights reserved. MAPBASIC. new_info_value must be a Brush expression. OBJ_INFO_BRUSH OBJ_INFO_TEXTFONT OBJ_INFO_SYMBOL OBJ_INFO_SMOOTH OBJ_INFO_FRAMEWIN OBJ_INFO_FRAMETITLE OBJ_INFO_TEXTSTRING OBJ_INFO_TEXTSPACING Reference Guide © 2006 MapInfo Corporation.g. OBJ_INFO_BRUSH) in both the ObjectInfo( ) function and the Alter Object statement.. 1.obj. new_info_value must be a string expression. The table below summarizes the values you can specify in the Info clause to perform various types of style alterations.

94 © 2006 MapInfo Corporation. The Geography clause lets you modify the same attributes that you can query through the ObjectGeography( ) function.Alter Object statement obj_info_code Value OBJ_INFO_TEXTJUSTIFY Result of Alter Object Changes a Text object's alignment. new_info_value must be 0 for no line. obj_geo_code Value OBJ_GEO_MINX OBJ_GEO_MINY OBJ_GEO_MAXX OBJ_GEO_MAXY OBJ_GEO_ARCBEGANGLE Result of Alter Object Alters object's minimum bounding rectangle. use the Node clause (described below) instead of the Geography clause.DEF. Alters beginning angle of an Arc object..DEF” if you intend to use the Alter Object…Geography statement. or 2 for a line with an arrow. OBJ_GEO_LINEENDY) Conversely. MapBasic 8. does not apply to Point objects. Alters object's MBR. does not apply to Point objects. or 2 for right-justified. Changes a Text object's label line setting. OBJ_GEO_LINEENDX) ObjectGeography(o_cable. you can obtain a line object's end coordinates by calling the ObjectGeography( ) function: Dim Dim x = y = o_cable As Object x. Your program should Include “MAPBASIC. Alters object's MBR. new_info_value must be 0 for left-justified. The table below summarizes the values you can specify in the Geography clause in order to perform various types of geographic alterations. 1 for center-justified. MAPBASIC. All rights reserved. The Geography clause applies to all object types except for polylines and regions. Alters object's MBR. y Note: You use the same codes (e. For example. To alter the coordinates of a polyline or region object. y As Float ObjectGeography(o_cable. 1 for simple line.g. Note that the obj_geo_code values are defined in the standard MapBasic definitions file. the following Alter Object statements let you alter the line object's end coordinates: Alter Object Geography Alter Object Geography o_cable OBJ_GEO_LINEENDX.5 . OBJ_GEO_LINEENDX) in both the ObjectGeography( ) function and the Alter Object statement. you can alter an object's geographical coordinates. OBJ_INFO_TEXTARROW Geography clause By issuing an Alter Object statement with a Geography clause. x o_cable OBJ_GEO_LINEENDY.

However. Alters a Line object's ending node. Create statements are somewhat restrictive. to add nodes as needed. Alters y coordinate of the end of a Text object's label line. The polygon_num parameter specifies which polygon in a multiple-polygon region (or which section in a multiple-section polyline) should be modified. you can add. Alters a Point object's y coordinate. If the Node clause includes a Remove sub-clause. Alters the diameter of the circle that defines the rounded corner of a Rounded Rectangle object. Alters a Point object's x coordinate. the statement removes a node. Your program can then issue an appropriate number of Alter Object…Node Add statements. Create statements allow you to create new polyline and region objects. Reference Guide © 2006 MapInfo Corporation. In some situations. you may not know how many nodes should go into an object until run-time. 95 . Alters a Line object's starting node.Alter Object statement obj_geo_code Value OBJ_GEO_ARCENDANGLE OBJ_GEO_LINEBEGX OBJ_GEO_LINEBEGY OBJ_GEO_LINEENDX OBJ_GEO_LINEENDY OBJ_GEO_POINTX OBJ_GEO_POINTY OBJ_GEO_ROUNDRADIUS Result of Alter Object Alters ending angle of an Arc object. If your program will not know until run-time how many nodes should comprise an object. The Alter Object statement's Node clause is often used in conjunction with the Create Pline statement and the Create Region statement. The polygon_num and node_num parameters should always be 1 (one) or greater. that let you specify exactly which node you want to reposition or remove. Within the Node clause. remove. Alters rotation angle of a Text object. Alters a Line object's ending node. because they force you to state at compile time the number of nodes that will comprise the object. the Alter Object statement adds a node to the object. Alters a Line object's starting node. the statement repositions a node. polygon_num and node_num. OBJ_GEO_TEXTLINEX OBJ_GEO_TEXTLINEY OBJ_GEO_TEXTANGLE Node clause By issuing an Alter Object statement with a Node clause. the Position sub-clause includes two parameters. The Position sub-clause is optional when you are adding a node. If the Node clause includes a Set Position sub-clause. or reposition nodes in a polyline or region object. Alters x coordinate of the end of a Text object's label line. All rights reserved. you can issue a Create Pline statement or a Create Region statement which creates an “empty” object (an object with zero nodes). If the Node clause includes an Add sub-clause.

OBJ_GEO_CENTROID is defined in MAPBASIC. which are all scalars. the following Alter Object statement allows you to reset the region part of a collection object: Alter Object obj_variable_name Info OBJ_INFO_REGION. and CentroidY( ) function. or if the point is not a valid centroid. you can reset collection parts (Region. Y) The user can also query the centroid by using the ObjectGeography( ) function as follows: PointObj = ObjectGeography(Obj. A point is needed in this instance because we need two values which define a point. • Multipoint: sets a Multipoint symbol as shown in the following: Alter Object obj_variable_mpoint Info OBJ_INFO_SYMBOL. OBJ_INFO_REGION) Also. The Point that is input is checked to make sure it is a valid Centroid (i.DEF. Multipoint Objects and Collections The Alter Object statement has been extended to support the following new object types.. PointObj Note that PointObj is a point object. you can determine a collection object's region part by calling the ObjectInfo( ) function: Dim ObjRegion As Object ObjRegion = ObjectInfo(Selection. CreatePoint(X. OBJ_GEO_CENTROID) There are other ways to get the Centroid. For example. 96 © 2006 MapInfo Corporation. ObjRegion Note: You use the same code (e. The Info clause allows you to modify the same attributes that you can query through the ObjectInfo( ) function.Alter Object statement Region Centroids The Centroid of a Region can be set by using the Alter Object command with the syntax noted below: Alter Object Obj Geography OBJ_GEO_CENTROID. MapBasic 8.. All rights reserved. it is inside the region). OBJ_INFO_REGION) in both the ObjectInfo( ) function and the Alter Object statement. then an error is returned. An easy way to center an X and Y value for a centroid is as follows: Alter Object Obj Geography OBJ_GEO_CENTROID. This differs from other values input by Alter Object Geography. including the Centroid( ) function.g. If the Obj is not a region.obj.5 . CentroidX( ) function. or if PointObj is not a point object. NewSymbol • Collection: By issuing an Alter Object statement with an Info clause. Polyline or Multipoint) inside the collection object.e.

ObjectInfo( ) function. Create Region statement. node_num is the number of a node to be changed. ObjectGeography( ) function. polygon_num is ignored for Multipoint. it is advisable to set it to 1. Alter Object obj Node statement To insert nodes within a Multipoint object: Dim mpoint_obj as object Create Multipoint Into Variable mpoint_obj 0 Alter Object mpoint_obj Node Add (0. Example Dim myobj As Object. 97 . Update statement Reference Guide © 2006 MapInfo Corporation. node_num mpoint_obj is a Multipoint object variable.Alter Object statement Support has also been added to the Alter Object statement that allows you to insert and delete nodes to/from Multipoint objects. Insert statement. To set nodes inside a Multipoint object: Alter Object mpoint_obj Node Set Position polygon_num.1) Alter Object mpoint_obj Node Add (2.1) Note: Nodes for Multipoint are always added at the end. use an Insert statement or an Update statement to store the object in a table. Rnd(1) * 100) Next Note: After using the Alter Object statement to modify an object. i As Integer Create Region Into Variable myobj 0 For i = 1 to 10 Alter Object myobj Node Add (Rnd(1) * 100. it is advisable to set it to 1. node_num (x. node_num is the number of a node to be removed. To delete nodes from a Multipoint object: Alter Object mpoint_obj Node Remove Position polygon_num. All rights reserved.y) mpoint_obj is a Multipoint object variable. polygon_num is ignored for Multipoint. See Also Create Pline statement. x and y are the new coordinates of the node node_num.

. rename columns..5 . thus. you can make all of the structural changes that you need to make (see example below).. an Alter Table statement can have up to five clauses. and can contain letters.. not the order of rows in the table.Alter Table statement Alter Table statement Purpose Alters the structure of a table. a table's first column appears at the top of an Info tool window.. column names can be up to 31 characters long. and change column ordering.] ] ) [ Interactive ] table is the name of an open table.. columnname is the name of a column. All rights reserved. 98 © 2006 MapInfo Corporation. Each columntype should be one of the following: integer. date. with a single Alter Table statement.. and column names cannot begin with numbers. Altogether.. Note: If you have edited a table. The Order clause lets you specify the order of the columns.] ] [ Order columnname. you must save or discard your edits before you can use the Alter Table statement. you can change the datatypes of existing columns. the first column appears at the left edge of a Browser window. Column order dictates the relative positions of the columns when you browse the table. oldcolumnname represents the previous name of a column to be renamed. . numbers. By including an Add clause in an Alter Table statement. The Order clause affects the order of the columns. A Drop clause lets you delete columns. Description The Alter Table statement lets you modify the structure of an open table. drop (delete) columns. . Similarly. allowing you to add columns.] ] [ Rename oldcolumnname newcolumnname [. SmallInt. columnname [. Note that each of these five clauses can operate on a list of columns.] ] [ Drop columnname [.] ] [ Modify columnname columntype [. while a Rename clause lets you change the names of existing columns. you can add new columns to your table. decplaces ). Syntax Alter Table table ( [ Add columnname columntype [. and the underscore character.. char(size). Cannot be used on linked tables. and the last column appears at the right edge. or logical.. float. columntype indicates the datatype of a table column (including the field width if necessary).. newcolumnname represents the intended new name of a column to be renamed. By including a Modify clause. . MapBasic 8. decimal( size. change column widths or datatypes. .

fipscode. you can determine the directory or folder from which the application is running. utmcode Add schoolcode SmallInt. an Order clause specifies the order for the new set of columns: the schoolcode column comes first. The Alter Table statement below makes several changes to the gcpop table. fipscode. representing a directory path. Open Table "gcpop" Alter Table gcpop (Rename pop_88 population Drop metsize. To determine the directory or folder where the MapInfo Professional software is installed. federalaid Float Order schoolcode. if you call the function by typing into the MapBasic window).. followed by the population column.ApplicationDirectory$( ) function If a MapBasic application issues an Alter Table statement affecting a table which has memo fields. Syntax ApplicationDirectory$( ) Return Value String expression. Create Index statement. ApplicationDirectory$( ) returns a null string. the memo fields will be lost. call the ProgramDirectory$( ) function. we have a hypothetical table. metsize. a Rename clause changes the name of the pop_88 column to population. No warning will be displayed.tab” which contains the following columns: pop_88.g. If no application is running (e. “gcpop. Description By calling the ApplicationDirectory$( ) function from within a compiled MapBasic application. Then the Drop clause deletes the metsize. Reference Guide © 2006 MapInfo Corporation. Create Map statement. An Add clause creates two new columns: a small (2-byte) integer column called schoolcode. 99 . and utmcode. If you include the Interactive keyword. First. MapInfo Professional 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. possibly causing the loss of themes or cosmetic objects. All rights reserved. Finally. and a floating point column called federalaid. etc. Create Table statement ApplicationDirectory$( ) function Purpose Returns a string containing the path from which the current MapBasic application is executing. and utmcode columns. fipscode. population. An Alter Table statement may cause map layers to be removed from a Map window. federalaid) See Also Add Column statement.

100 © 2006 MapInfo Corporation. See Set Area Units statement on page 557 for the list of available unit names. a Cartesian operation is performed. Syntax Area( obj_expr. for example. For the most part. a spherical operation is performed unless the coordinate system is NonEarth. the area of a point. specify “acre” as the unit_name parameter. MapBasic calculates the area of a rounded rectangle as if the object were a conventional rectangle. unit_name is a string representing the name of an area unit (e. Return Value Float Description The Area( ) function returns the area of the geographical object specified by obj_expr. text. sAppPath might look like this: ' ' "C:\MAPBASIC\CODE\" See Also ProgramDirectory$( ) function Area( ) function Purpose Returns the geographical area of an Object. unit_name ) obj_expr is an object expression.Area( ) function Example Dim sAppPath As String sAppPath = ApplicationDirectory$( ) ' At this point. to obtain an area in acres. The function returns the area measurement in the units specified by the unit_name parameter. arc. line. MapBasic 8. The Area( ) function returns approximate results when used on rounded rectangles. or polyline object is zero. Generally. in which case. All rights reserved. Only regions.5 .g. By definition. MapInfo Professional performs a Cartesian or Spherical operation. and rounded rectangles have any area. “sq km”).. ellipses. rectangles.

Dim f_sq_miles As Float Open Table "states" Fetch First From states f_sq_miles = Area(states. Note that the expression tablename. as shown in the following example. Select state. Set Area Units statement AreaOverlap( ) function Purpose Returns the area resulting from the overlap of two closed objects. Return Value A float value representing the area (in MapBasic's current area units) of the overlap of the two objects. See Also Overlap( ) function.obj) represents the geographical object of the current row in the specified table. "sq mi") You can also use the Area( ) function within the SQL Select statement. Set Area Units statement Reference Guide © 2006 MapInfo Corporation.AreaOverlap( ) function Examples The following example shows how the Area( ) function can calculate the area of a single geographic object. 101 . "sq km") From states Into results See Also ObjectLen( ) function.obj (as in states.obj. CartesianArea( ) function. Perimeter( ) function. Area(obj. ProportionOverlap( ) function. SphericalArea( ) function. object2 ) object1 and object2 are closed objects. All rights reserved. Syntax AreaOverlap( object1.

Asc( ) returns a number in the range 0 255. ' since 65 is the code for the letter A See Also Chr$( ) function 102 © 2006 MapInfo Corporation. Syntax Asc( string_expr ) string_expr is a string expression.5 . All rights reserved. On systems that do not support double-byte character sets.g. On a system that supports double-byte character sets (e.Asc( ) function Asc( ) function Purpose Returns the character code for the first character in a string expression.535. if the first character of string_expr is a double-byte character. MapBasic 8. Example Dim code As SmallInt code = Asc("Afghanistan") ' code will now be equal to 65.. Asc( ) returns a number in the range 0 . the Asc( ) function returns a value of zero.255. Return Value Integer Description The Asc( ) function returns the character code representing the first character in the string specified by string_expr. Note: All MapInfo Professional environments have common character codes within the range of 32 (space) to 126 (tilde). Asc( ) returns a value in the range 256 65. If string_expr is a null string. Windows Japanese): if the first character of string_expr is a single-byte character.

(Note that your program will need to Include “MAPBASIC. expressed in radians. multiply that value by DEG_2_RAD.Asin( ) function Asin( ) function Purpose Returns the arc-sine value of a number. Sin( ) function. Cos( ) function. Return Value Float Description The Asin( ) function returns the arc-sine of the numeric num_expr value.DEF” in order to reference DEG_2_RAD or RAD_2_DEG).5 y = Asin(x) * RAD_2_DEG ' y will now be equal to 30. Asin( ) returns the angle whose sine is equal to num_expr. In other words. ' since the sine of 30 degrees is 0. and given that Pi/2 radians represents 90 degrees). multiply that value by RAD_2_DEG.DEF" Dim x. Syntax Asin( num_expr ) num_expr is a numeric expression from one to negative one. To convert a degree value to radians. Example Include "MAPBASIC. The result returned from Asin( ) represents an angle. To convert a radian value into degrees.5 See Also Acos( ) function. 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). y As Float x = 0. Atn( ) function. This angle will be somewhere between -Pi/2 and Pi/2 radians (given that Pi is approximately equal to 3. All rights reserved. inclusive. 103 . Tan( ) function Reference Guide © 2006 MapInfo Corporation.141593.

. such as “File already exists. cancel_text is a string (e. asking the user a yes-or-no question. Example Dim more As Logical more = Ask("Do you want to continue?". The ok_text parameter specifies the name of the Yes-answer button (e. ok_text. If the user clicks the cancel_text button or otherwise cancels the dialog box (e. and the cancel_text parameter specifies the name of the No-answer button (e. you can use the Dialog statement instead of calling the Ask( ) function. the Ask( ) function returns FALSE.g. If you need to display phrases that are too long to fit in small dialog box buttons. The prompt parameter specifies a message. cancel_text ) prompt is a string to appear as a prompt in the dialog box. Since the buttons are limited in size.g. Print statement 104 © 2006 MapInfo Corporation. “Cancel” or “Stop”). the ok_text and cancel_text strings should be brief.Ask( ) function Ask( ) function Purpose Displays a dialog box.. “OK”) that appears on the confirmation button. Note statement. the Ask( ) function returns TRUE. Syntax Ask( prompt. ok_text is a string (e.. The dialog box contains two buttons. "Stop") See Also Dialog statement. asking the user a yes or no (OK or Cancel) question. 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). All rights reserved. or click the other button to give a No answer.. If the user selects the ok_text button.g. MapBasic 8. by pressing the Esc key).5 . the user can click one button to give a Yes answer to the prompt. “Cancel”) that appears on the cancel button. Return Value Logical Description The Ask( ) function displays a dialog box. do you want to continue?” The prompt string can be up to 300 characters long. "OK".g. “OK” or “Continue”).g..

To convert a radian value into degrees. Sin( ) function. All rights reserved. In other words. The num_expr expression can have any numeric value. in the range -Pi/2 radians to Pi/2 radians.Atn( ) function Atn( ) function Purpose Returns the arc-tangent value of a number. The result returned from Atn( ) represents an angle. expressed in radians.DEF" Dim val As Float val = Atn(1) * RAD_2_DEG 'val is now 45.DEF” in order to reference DEG_2_RAD or RAD_2_DEG). since the 'Arc tangent of 1 is 45 degrees See Also Acos( ) function. 105 . multiply that value by RAD_2_DEG. (Note that your program will need to Include “MAPBASIC. To convert a degree value to radians. multiply that value by DEG_2_RAD. Tan( ) function Reference Guide © 2006 MapInfo Corporation. Return Value Float Description The Atn( ) function returns the arc-tangent of the numeric num_expr value. Asin( ) function. Example Include "MAPBASIC. Syntax Atn( num_expr ) num_expr is a numeric expression. Cos( ) function. Atn( ) returns the angle whose tangent is equal to num_expr.

This setting defaults to Off (MapInfo Professional will not draw overlapping labels).AutoLabel statement AutoLabel statement Purpose Draws labels in a Map window.. Example Open Table "world" Interactive Open Table "worldcap" Interactive Map From world. If you specify Selection. To control font and position settings through MapBasic. All rights reserved. Syntax AutoLabel [ Window window_id ] [ { Selection | Layer layer_id } ] [ Overlap [ { On | Off } ] ] [ Duplicates [ { On | Off } ] ] window_id is an integer window identifier for a Map window. all layers are labeled. worldcap AutoLabel Window FrontWindow( ) Layer world See Also Set Map statement 106 © 2006 MapInfo Corporation. World) or a SmallInt layer number (e. The Overlap clause controls whether MapInfo Professional draws labels that overlap other labels. Description The AutoLabel statement draws labels (text objects) in a Map window. If you omit both the Selection and the Layer clause. MapInfo Professional draws labels in the front-most Map window. Set label options by choosing Map > Layer Control. and stores the labels in the Cosmetic layer. issue a Set Map statement. The Window clause controls which Map window is labeled.g. If you omit the Window clause. The AutoLabel statement uses whatever font and position settings are in effect. This setting defaults to Off (duplicates not allowed). To force MapInfo Professional to draw a label for every map object. only selected objects are labeled. The Duplicates clause controls whether MapInfo Professional draws a new label for an object that has already been labeled. regardless of whether the labels overlap..5 .g. Only objects that are currently visible in the Map window are labeled. layer_id is a table name (e. specify Overlap On. 1 to draw labels for the top layer). MapBasic 8.

table is a string representing the name of an open table. y ) [ Units paper_units ] ] [ Width window_width [ Units paper_units ] ] [ Height window_height [ Units paper_units ] ] [ Row n ] [ Column n ] [ Min | Max ] expression_list is either an asterisk or a comma-separated list of column expressions. Browse statement Purpose Opens a new Browser window. Syntax Beep Description The Beep statement sends a sound to the speaker. the expression_list clause can consist of a comma-separated list of expressions. n is a positive integer value. window_width and window_height specify the size of the Browser. Syntax Browse expression_list From table [ Position ( x. All rights reserved. If the expression_list is simply an asterisk (*). Each column's name is derived from the expression that defines the column. Thus. x. the new Browser includes all fields in the table. “cm” for centimeters). y specifies the position of the upper left corner of the Browser. paper_units is a string representing a paper unit name (for example. each of which defines one column that is to appear in the Browser. in paper_units.Beep statement Beep statement Purpose Makes a beeping sound. operators. Description The Browse statement opens a Browse window to display a table. in paper_units. Alternately. if a column is defined by the expression population / Reference Guide © 2006 MapInfo Corporation. functions. and variables. 107 . Expressions in the list can contain column names.

the table's first column will appear at the left edge of the Browser window. MapBasic 8. follow the expression with a string. taking up all of the screen space available to MapInfo. Open Table "world" Browse country. as the column name. that expression will appear on the top row of the Browser. Set Window statement 108 © 2006 MapInfo Corporation. If the Browse statement includes the optional Max keyword. the Column clause dictates which of the table's columns should appear at the left edge of the Browser. To assign an alias to an expression. If the Browse statement does not include a Column clause. Through the third expression. see the example below. unless the table does not have enough rows to fill a Browser window that large.Browse statement area(obj. The first two columns represent data as it is stored in the World table. the Browser window is minimized immediately. and the Browser width will depend on the widths of the fields in the table. If no Width and Height clauses are provided. Similarly. population. The y coordinate specifies the distance from the top of the MapInfo Professional window down to the top of the Browser. the resultant Browser window is maximized. “acre”). The Row clause dictates which row of the table should appear at the top of the Browser. MapInfo Professional assigns the Browser window a default size which depends on the table in question: the Browser height will generally be one quarter of the screen height. The optional Width and Height clauses specify the size of the Browser window. while the third column is derived. Open Table "world" Browse * From world The next example specifies exactly which column expressions from the World table should be displayed in the Browser. An optional Position clause lets you specify where on the screen to display the Browser. If the Browse statement does not include a Row clause. The x coordinate specifies the distance (in paper units) from the left edge of the MapInfo Professional application window to the left edge of the Browser. the first row of the table will be the top row in the Browser. MapBasic divides the population of each country record with the geographic area of the region associated with that record. population/area(obj. "sq km") "Density" From world The resultant Browser has three columns. The derived column expression has an alias (“Density”) which appears on the top row of the Browse window. All rights reserved. if the Browse statement includes the Min keyword. See Also Set Browse statement. Example The following example opens the World table and displays all columns from the table in a Browser window. in paper units.5 . Conversely.

109 . and background color) within parentheses: Brush(64. Various object-related statements. BLUE) With some MapBasic statements (e. foreground color. WHITE. MAGENTA. The keyword Brush may be followed by an expression which evaluates to a Brush value. Integer RGB color value. a set of color and pattern settings that dictate the appearance of a filled object.) or a Brush variable..Brush clause Brush clause Purpose Specifies a fill style for graphic objects. such as MakeBrush( pattern. MAPBASIC. The Alter Object statement is one example. BLUE. background color) that define a Brush: Component pattern foreground color Description Integer value from 1 to 8 or from 12 to 71. This expression can be a Brush variable: Brush br_var or a call to a function which returns a Brush value: Brush MakeBrush(64. includes Define statements for BLACK. bgcolor ). the name of a Brush variable). (See MakeBrush( ) function on page 362 for more information. The following table summarizes the three components (pattern. not a complete MapBasic statement. such as Create Ellipse statement. Set Map statement). the keyword Brush can be followed immediately by the three parameters that define a Brush style ( pattern. All rights reserved. Description The Brush clause specifies a brush style—in other words. and YELLOW.DEF. rather than a full Brush clause (the keyword Brush followed by the name of a Brush variable).g. Integer RGB color value. CYAN. The definitions file. fgcolor. Brush is a clause. see RGB( ) function.g. CYAN. GREEN. see table below. background color Reference Guide © 2006 MapInfo Corporation. BLUE) Some MapBasic statements take a Brush expression as a parameter (e. CYAN.. allow you to specify a brush value. Syntax Brush brush_expr brush_expr is a Brush expression. such as a circle or rectangle. RED. foreground color.

See Also CurrentBrush( ) function. To specify a transparent background when calling the MakeBrush( ) function specify -1 as the background color.Brush clause To specify a transparent background. MapBasic 8. For example. Font clause. Symbol clause 110 © 2006 MapInfo Corporation. All rights reserved. and omit the background color from the Brush clause.com/documentation/software/ mapinfo_pro/english/8.pdf.mapinfo. Note: A more comprehensive list of the fill patterns available in MapInfo Professional is in the MapInfo Professional User Guide Unabridged. Pen clause. The available patterns appear below. BLUE) to see thin blue stripes with no background fill color.0/MI_UG. Pattern 2 produces a solid fill. which is available on the MapInfo Professional installation CD or http://extranet. MakeBrush( ) function. specify Brush(5.5 . Omitting the background parameter is like clearing the Background check box in MapInfo Professional's Region Style dialog box. pattern 1 produces no fill. use pattern 3 or larger.

and the object is a linear object (line.8) o_region = Buffer( o_line. Return Value Returns a region object. 10. polyline. Description The Buffer( ) function returns a region representing a buffer. then the absolute value of width is used to produce a positive buffer.g. Example The following program creates a line object. unit_name ) inputobject is an object expression. 111 . arc) or a point. The buffer region extends ten miles in all directions from the line. -73. “km” for kilometers) used by width. resolution. If it is NonEarth. then a Cartesian method will be used. Otherwise. the object returned represents an object smaller than the original object..Buffer( ) function Buffer( ) function Purpose Returns a region object that represents a buffer region (the area within a specified buffer distance of an existing object).5. width. and if inputobject is a closed object. If the width is negative. 42. resolution is a SmallInt value representing the number of nodes per circle at each corner. width is a float value representing the radius of the buffer. if width is negative. use the Create Object As Buffer statement. The method used to calculate the buffer depends on the coordinate system. The Buffer( ) function operates on one single object at a time. a spherical method will be used. Dim o_line. All rights reserved. unit_name is the name of the distance unit (e. 42. “mi” for miles. The object will be created using the current MapBasic coordinate system. o_region As Object o_line = CreateLine(-73. To create a buffer around a set of objects. then creates a buffer region surrounding the line. 20.6. "mi") See Also Create Object statement Reference Guide © 2006 MapInfo Corporation.5. Syntax Buffer( inputobject.

def" If ButtonPadInfo("Main". if pad is floating. Integer.. Description The attribute parameter specifies what to return.. “Drawing”. Return Value Depends on the attribute parameter specified. All rights reserved. see table below. TRUE means the pad is floating. “Tools” or “Standard” to query the standard pads.ButtonPadInfo( ) function ButtonPadInfo( ) function Purpose Returns information about a ButtonPad. this is an integer. BTNPAD_INFO_FLOATING) Then '. use “Main”.5 . SmallInt: The width of the pad. now let's dock it. SmallInt. in paper units such as inches. BTNPAD_INFO_NBTNS BTNPAD_INFO_WIDTH BTNPAD_INFO_WINID BTNPAD_INFO_X BTNPAD_INFO_Y Example Include "mapbasic. Alter ButtonPad "Main" ToolbarPosition(0. Codes are defined in MAPBASIC.DEF attribute code BTNPAD_INFO_FLOATING ButtonPadInfo( ) returns: Logical. MapBasic 8.0) Fixed End If 112 © 2006 MapInfo Corporation. attribute is a code indicating which information to return. or specify the name of a custom pad. A number indicating the y-position of the upper-left corner of the pad. The window ID of the specified pad. expressed as a number of buttons (not including separators). A number indicating the x-position of the upper-left corner of the pad. The number of buttons on the pad. zero or greater.then the Main pad is floating. this is a float value. attribute ) pad_name is a string representing the name of an existing ButtonPad. Syntax ButtonPadInfo( pad_name. FALSE means the pad is docked. If pad is docked.

Description The Call statement calls a procedure.Call statement See Also Alter ButtonPad statement Call statement Purpose Calls a sub procedure or an external routine (DLL. then calls to that sub procedure may appear in either of the following forms: Call subroutine or Call subroutine( ) By default. This requirement is independent of whether the procedure is a conventional MapBasic Sub procedure. and continues until encountering an End Sub or an Exit Sub statement. Syntax Call subproc [ ( [ parameter ] [ . A MapBasic program must issue a Declare Sub statement to define the name and parameter list of any procedure which is to be called. then executes the statements following the Call statement.” When a sub procedure has a by-reference parameter. each sub procedure parameter is defined “by reference. Reference Guide © 2006 MapInfo Corporation. 113 . Parameter Passing Sub procedures may be defined with no parameters.. The procedure is usually a conventional MapBasic sub procedure (defined through the Sub…End Sub statement). MapBasic returns from the sub procedure. parameter is a parameter expression to pass to the sub procedure. If a particular sub procedure has no parameters. The Call statement can only access sub procedures which are part of the same application.. ] ) ] subproc is the name of a sub procedure. Restrictions You cannot issue a Call statement through the MapBasic window. All rights reserved. a program running under MapInfo Professional can call a Windows Dynamic Link Library (DLL) routine through the Call statement. the caller must specify the name of a variable to pass as the parameter. MapBasic begins executing the statements in the specified sub procedure. Alternately. At that time. . a DLL procedure or an XCMD. When a Call statement calls a conventional MapBasic procedure. XCMD).

This allows the caller to examine the results returned by the sub procedure. the first parameter contains the number to be cubed. you cannot specify array variables or variables of custom data Types as parameters.g.EXE”). result) ' result now contains the value: 8 (2 x 2 x 2) x = 1 Call Cube( x + 2. Sub…End Sub statement 114 © 2006 MapInfo Corporation. Declare Sub Cube(ByVal original As Float. When a parameter is passed by value. result As Float Call Cube( 2. cubed = original ^ 3 End Sub See Also Declare Sub statement. “KERNEL. and store ' the result in the "cubed" parameter. The sub procedure takes two parameters. Calling External Routines When a Call statement calls a DLL routine.Call statement If the procedure then alters the contents of the by-reference parameter. result) ' result now contains the value: 27 (3 x 3 x 3) End Program Sub Cube (ByVal original As Float. if a Call statement calls an XCMD. The specified DLL file must be present at run-time for MapBasic to complete a DLL Call. thus. cubed As Float) ' Cube the "original" parameter. Similarly. When calling XCMDs. without parentheses. rather than having to pass the name of a variable. When a sub procedure expects an array as a parameter. All rights reserved. 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. Exit Sub statement. The specified DLL routine is actually located in a separate file (e. cubed As Float) Dim x. MapBasic executes the routine until the routine returns. Global statement. and returns the result. Example In the following example. MapBasic 8. the file containing the XCMD must be present at runtime. the sub procedure Cube cubes a number (raises the number to the power of three). the caller should specify the name of an array variable. the sub procedure receives a copy of the value of the parameter expression.. the caller can pass any expression. and the second parameter passes the results back to the caller. A sub procedure can take an entire array as a single parameter.5 . Alternately. the caller's variable is automatically updated to reflect the change.

By definition. The function returns the area measurement in the units specified by the unit_name parameter. and rounded rectangles have any area. unit_name is a string representing the name of an area unit (e.. specify “acre” as the unit_name parameter. rectangles. Syntax CartesianArea( obj_expr. Dim f_sq_miles As Float Open Table "counties" Fetch First From counties f_sq_miles = CartesianArea(counties. See the Set Area Units statement for the list of available unit names. “sq km”). projected coordinate system using a Cartesian algorithm. All rights reserved.CartesianArea( ) function CartesianArea( ) function Purpose Returns the area as calculated in a flat. unit_name ) obj_expr is an object expression. Note that the expression tablename. or polyline object is zero. A value of -1 will be returned for data that is in a Latitude/Longitude since the data is not projected. Examples The following example shows how the CartesianArea( ) function can calculate the area of a single geographic object. The CartesianArea( ) function will always return the area using a cartesian algorithm. The CartesianArea( ) function returns approximate results when used on rounded rectangles. for example. "sq mi") You can also use the CartesianArea( ) function within the Select statement. as shown in the following example.obj. Only regions. Return Value Float Description The CartesianArea( ) function returns the Cartesian area of the geographical object specified by obj_expr. 115 .obj (as in states. to obtain an area in acres. CartesianArea(obj. MapBasic calculates the area of a rounded rectangle as if the object were a conventional rectangle. line. arc.g. Select lakes. the CartesianArea( ) of a point. ellipses. text.obj) represents the geographical object of the current row in the specified table. "sq km") From lakes Into results Reference Guide © 2006 MapInfo Corporation.

. 42.5 .CartesianBuffer( ) function See Also Area( ) function.5. if width is negative. o_region As Object o_line = CreateLine(-73. Return Value Region Object Description The CartesianBuffer( ) function returns a region representing a buffer and operates on one single object at a time. then the absolute value of width is used to produce a positive buffer. arc) or a point. Dim o_line. unit_name ) inputobject is an object expression. MapBasic 8. All rights reserved. -73. “km” for kilometers) used by width.5. If the inputobject is in a Latitude/Longitude Projection. and the object is a linear object (line. To create a buffer around a set of objects.6. Syntax CartesianBuffer( inputobject. “mi” for miles. Example The following program creates a line object. "mi") See Also Buffer( ) function. width. width is a float value representing the radius of the buffer. and if inputobject is a closed object. the object returned represents an object smaller than the original object. then Spherical calculations will be used regardless of the Buffer function used. resolution. resolution is a SmallInt value representing the number of nodes per circle at each corner. 10. unit_name is the name of the distance unit (e.8) o_region = CartesianBuffer( o_line. 42. Creating Map Objects 116 © 2006 MapInfo Corporation. polyline. use the Create Object As Buffer statement. then creates a buffer region that extends 10 miles surrounding the line. 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). 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.g. 20. If width is negative.

Description One point of the resulting Polyline object is on object1 and the other point is on object2. If there are multiple instances where the minimum or maximum distance exists (e. min) object1 and object2 are object expressions. Syntax CartesianDistance( x1. If the calculation cannot be done using a cartesian distance method (e. y1. All rights reserved. There is no way to determine if the object returned is uniquely the shortest distance.g. unit_name is a string representing the name of a distance unit (e. Note that the distance between the two input objects can be calculated using the ObjectLen( ) function.CartesianConnectObjects( ) function CartesianConnectObjects( ) function Purpose Returns an object representing the shortest or longest distance between two objects. CartesianDistance( ) function Purpose Returns the distance between two locations... “km”).. unit_name ) x1 and x2 are x-coordinates. object2. Return Value This statement returns a single section. and FALSE calculates the maximum distance between objects. y2. min is a logical expression where TRUE calculates the minimum distance between the objects. then this function will produce an error. if the MapBasic Coordinate System is Lat/Long). 117 . CartesianConnectObjects( ) returns a Polyline object connecting object1 and object2 in the shortest (min == TRUE) or longest (min == FALSE) way using a cartesian calculation method.g.g. x2. y1 and y2 are y-coordinates. Reference Guide © 2006 MapInfo Corporation. two-point Polyline object representing either the closest distance (min == TRUE) or farthest distance (min == FALSE) between object1 and object2. Syntax CartesianConnectObjects(object1. 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.

object2. You can reset MapBasic's coordinate system through the Set CoordSys statement. The x. A value of -1 is returned for data that is in a Latitude/Longitude coordinate system. end_y As Float Open Table "cities" Fetch First From cities start_x = CentroidX(cities.obj) end_y = CentroidY(cities.obj) start_y = CentroidY(cities. MapInfo Professional expects coordinates to use a Latitude/Longitude coordinate system. Distance( ) function CartesianObjectDistance( ) function Purpose Returns the distance between two objects.and y-coordinate parameters must use MapBasic's current coordinate system. to obtain a distance in miles. Return Value Float 118 © 2006 MapInfo Corporation. See Set Distance Units statement for the list of available unit names.obj) Fetch Next From cities end_x = CentroidX(cities. start_y. The CartesianDistance( ) function always returns a value using a cartesian algorithm.end_x. Example Dim dist. CartesianDistance( ) function. It returns the distance measurement in the units specified by the unit_name parameter. start_x.start_y.end_y. unit_name) object1 and object2 are object expressions. By default. MapBasic 8.obj) dist = CartesianDistance(start_x. All rights reserved. specify “mi” as the unit_name parameter. end_x. for example. unit_name is a string representing the name of a distance unit.CartesianObjectDistance( ) function Return Value Float Description The CartesianDistance( ) function calculates the Cartesian distance between two locations.5 . since Latitude/Longitude data is not projected and not cartesian."mi") See Also Math Functions. Syntax CartesianObjectDistance(object1.

to obtain a length in miles.g. Syntax CartesianObjectLen( obj_expr. Note that only line and polyline objects have length values greater than zero. ellipse. The CartesianObjectLen( ) function returns a length measurement in the units specified by the unit_name parameter.g. CartesianObjectLen( ) function. unit_name ) obj_expr is an object expression. unit_name is a string representing the name of a distance unit (e. to measure the circumference of a rectangle. in miles See Also SphericalObjectLen( ) function.obj. if the MapBasic Coordinate System is Lat/Long). Return Value Float Description The CartesianObjectLen( ) function returns the length of an object expression. for example. The CartesianObjectLen( ) function will always return a value using a cartesian algorithm. “km”). then this function will produce an error. use the Perimeter( ) function. since Latitude/ Longitude data is not projected and not cartesian. A value of -1 will be returned for data that is in a Latitude/Longitude coordinate system... All rights reserved. or region. Example Dim geogr_length As Float Open Table "streets" Fetch First From streets geogr_length = CartesianObjectLen(streets. ObjectLen( ) function Reference Guide © 2006 MapInfo Corporation. CartesianObjectLen( ) function Purpose Returns the geographic length of a line or polyline object. See the Set Distance Units statement for the list of valid unit names. If the calculation cannot be done using a cartesian distance method (e. "mi") ' geogr_length now represents the length of the ' street segment.CartesianObjectLen( ) function Description CartesianObjectDistance( ) returns the minimum distance between object1 and object2 using a cartesian calculation method with the return value in unit_name. specify “mi” as the unit_name parameter. 119 .

distance. If the coordinate system is Lat/Long. 100. If the coordinate system of the input object is Lat/Long. This is signified by returning a NULL object. 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 center of the bounding box). the actual offset delta is calculated at some fixed point on the object (e. The DistanceType used is Cartesian.CartesianOffset( ) Function CartesianOffset( ) Function Purpose Returns a copy of the input object offset by the specified distance and angle using a Cartesian DistanceType. is the unit for the distance value. The unit string. 45. the shape of the object remains the same. and then that value is converted from the input units into the coordinate system's units. For the Offset functions. units ) object is the object being offset. Example CartesianOffset(Rect. distance is the distance to offset the object. similar to that used for ObjectLen( ) function or Perimeter( ) function. angle is the angle to offset the object. since Cartesian DistanceTypes are not valid for Lat/Long. and the actual measured distance for a degree is different at different locations. "mi") See Also CartesianOffsetXY( ) Function 120 © 2006 MapInfo Corporation. If you move an object that is in Lat/Long.5 . 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. an error will occur. units is a string representing the unit in which to measure distance.. The actual converted distance measurement could vary at different locations on the object. angle. the conversion to degrees uses the fixed point. MapBasic 8.g. Syntax CartesianOffset( object. This is because you are picking one offset delta in degrees. The distance from the input object and the new offset object is only guaranteed to be exact at the single fixed point used. but the area of the object will change. All rights reserved.

the shape of the object remains the same. xoffset and yoffset are the distance along the x and y axes to offset the object. 45. 100. There are some considerations for Spherical measurements that do not hold for Cartesian measurements.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. 121 . If the coordinate system of the input object is Lat/Long. If the coordinate system is Lat/Long. and the actual measured distance for a degree is different at different locations. and then that value is converted from the input units into the coordinate system's units. "mi") See Also CartesianOffset( ) Function Reference Guide © 2006 MapInfo Corporation. similar to that used for ObjectLen( ) function or Perimeter( ) function. an error will occur. Example CartesianOffset(Rect. All rights reserved. the actual offset delta is calculated at some fixed point on the object (e. This is because you are picking one offset delta in degrees.g.. yoffset. The actual converted distance measurement could vary at different locations on the object. If you move an object that is in Lat/Long. units is a string representing the unit in which to measure distance. the center of the bounding box). Syntax CartesianOffsetXY( object. For the Offset functions. units ) object is the object being offset. since Cartesian DistanceTypes are not valid for Lat/Long. but the area of the object will change. The DistanceType used is Cartesian. Return Value Object Description This function produces a new object that is a copy of the input object offset by xoffset along the Xaxis and yoffset along the Y-axis. This is signified by returning a NULL object. is the unit for the distance values. xoffset. the conversion to degrees uses the fixed point. The coordinate system used is the coordinate system of the input object. The unit string. The distance from the input object and the new offset object is only guaranteed to be exact at the single fixed point used.

You can also use the CartesianPerimeter( ) function within the Select statement. rounded rectangles. Other types of objects have perimeter measurements of zero. The following Select statement extracts information from the States table. "km") ' The variable perim now contains ' the perimeter of the polygon that's attached to ' the first record in the World table. since Latitude/ Longitude data is not projected and not Cartesian.5 . to obtain a length in miles. MapBasic 8. and polygons. Syntax CartesianPerimeter( obj_expr . unit_name ) obj_expr is an object expression.CartesianPerimeter( ) function CartesianPerimeter( ) function Purpose Returns the perimeter of a graphical object. A value of -1 will be returned for data that is in a Latitude/Longitude coordinate system. The CartesianPerimeter( ) function will always return a value using a Cartesian algorithm.g. the Results table will include a column showing each state's perimeter. Dim perim As Float Open Table "world" Fetch First From world perim = CartesianPerimeter(world. Return Value Float Description The CartesianPerimeter( ) function calculates the perimeter of the obj_expr object. specify “mi” as the unit_name parameter. “km”).obj. All rights reserved. MapBasic calculates the perimeter of a rounded rectangle as if the object were a conventional rectangle. The CartesianPerimeter( ) function returns a length measurement in the units specified by the unit_name parameter.. 122 © 2006 MapInfo Corporation. and stores the results in a temporary table called Results. CartesianPerimeter( ) returns approximate results when used on rounded rectangles. rectangles. See the Set Distance Units statement for the list of valid unit names. Example The following example shows how you can use the CartesianPerimeter( ) function to determine the perimeter of a particular geographic object. unit_name is a string representing the name of a distance unit (e. for example. Because the Select statement includes the CartesianPerimeter( ) function. The Perimeter( ) function is defined for the following object types: ellipses.

If the obj_expr parameter represents a line object. and placement of thematic pie and bar charts. CartesianPerimeter(obj. the Centroid( ) function returns the point midway between the ends of the line. Syntax Centroid( obj_expr ) obj_expr is an object expression. Perimeter( ) function Centroid( ) function Purpose Returns the centroid (center point) of an object.Centroid( ) function Open Table "states" Select state. the centroid position is halfway between the upper and lower extents of the object. and therefore may not be located halfway between the object's extents. Example Dim pos As Object Open Table "world" Fetch First From world pos = Centroid(world. the Centroid( ) function returns a point located at the mid point of the middle segment of the polyline. SphericalPerimeter( ) function. however. you can reposition region centroids by dragging them. the centroid position is always on the object in question. "mi") From states Into results See Also CartesianPerimeter( ) function. If the obj_expr parameter represents any other type of object. and halfway between the left and right extents. the Centroid( ) function returns the position of the point. which is located at the centroid of the specified obj_expr object. geocoding. A region's centroid does not represent its center of mass. text. it represents the location used for automatic labeling. the Centroid( ) function returns a point located at the true centroid of the original object. and ellipse objects. For region objects. If you edit a map in reshape mode. Instead. For rectangle. 123 . arc. If the obj_expr parameter represents a polyline object. All rights reserved. If the obj_expr parameter represents a point object. Return Value Point object Description The Centroid( ) function returns a point object.obj) Reference Guide © 2006 MapInfo Corporation.

5 . regions.. Dim x As Float Open Table "world" Fetch First From world x = CentroidX(world. and stores the results in a temporary table called Results. Set CoordSys statement 124 © 2006 MapInfo Corporation. CentroidY( ) function CentroidX( ) function Purpose Returns the x-coordinate of the centroid of an object. CentroidX(obj). MapBasic 8. All rights reserved. Open Table "world" Select country.CentroidX( ) function See Also Alter Object statement. the Results table will include columns which display the longitude and latitude of the centroid of each country. Longitude) component of the centroid of the specified object. CentroidX( ) function. MapBasic uses a Longitude/Latitude coordinate system. Syntax CentroidX( obj_expr ) obj_expr is an object expression Return Value Float Description The CentroidX( ) function returns the X coordinate (e. by default. The following Select statement extracts information from the World table. The Set CoordSys statement allows you to change the coordinate system used.obj) You can also use the CentroidX( ) function within the Select statement. The coordinate information is returned in MapBasic's current coordinate system. Examples The following example shows how the CentroidX( ) function can calculate the longitude of a single geographic object. CentroidY( ) function. CentroidY(obj) From world Into results See Also Centroid( ) function. etc. 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.). Because the Select statement includes the CentroidX( ) function and the CentroidY( ) function.g.

see table below. latitude) component of the centroid of the specified object. etc. 125 . Return Value Float Description The CentroidY( ) function returns the Y-coordinate (e. with respect to different types of graphical objects (lines vs.CentroidY( ) function CentroidY( ) function Purpose Returns the y-coordinate of the centroid of an object. Set CoordSys statement CharSet clause Purpose Specifies which character set MapBasic uses for interpreting character codes.). Example Dim y As Float Open Table "world" Fetch First From world y = CentroidY(world.. CentroidX( ) function. MapBasic uses a Longitude/Latitude coordinate system. All rights reserved. by default.g. Syntax CharSet char_set char_set is a string that identifies the name of a character set. See the Centroid( ) function for a discussion of what the concept of a centroid position means. The coordinate information is returned in MapBasic's current coordinate system. Syntax CentroidY( obj_expr ) obj_expr is an object expression. Reference Guide © 2006 MapInfo Corporation.obj) See Also Centroid( ) function. regions. The Set CoordSys statement allows you to change the coordinate system used.

if Windows is configured to use a different character set. What Is A Character Set? Every character on a computer keyboard corresponds to a numeric code. How Do Character Sets Affect MapBasic Programs? If your files use only standard ASCII characters in the range of 32 (space) to 126 (tilde).. For example. and a set of numeric codes that correspond to those characters.5 . in the version of Windows for North America and Western Europe. characters outside the range 32 to 126). The CharSet clause takes one parameter: a string expression which identifies the name of the character set to use. the letter “A” corresponds to the character code 65. For example. you do not need to use the CharSet clause. Even if your files include “special” characters (i. MapBasic 8. All rights reserved. character code 176 corresponds to a degrees symbol. character code 176 may represent a different character. not a complete statement. you do not need to worry about character set conflicts. The following table lists all character sets available. Call SystemInfo(SYS_INFO_CHARSET) to determine the character set in use at run-time. The CharSet clause should indicate what character set was in use when the file was created. If your program needs to read an existing file that contains “special” characters.e. Note that CharSet is a clause.g. and if the file was created in a character set that does not match the character set in use when you run your program. your program should use the CharSet clause. if you do all of your work within one environment (e.CharSet clause Description The CharSet clause specifies which character set MapBasic should use when reading or writing files or tables. A character set is a set of characters that appear on a computer. Different character sets are used in different countries. such as the Open File statement. and you do not need to use the CharSet clause. however. Various file-related statements. ISO 8859-1 (UNIX) ISO 8859-2 (UNIX) ISO 8859-3 (UNIX) ISO 8859-4 (UNIX) ISO 8859-5 (UNIX) ISO 8859-6 (UNIX) 126 © 2006 MapInfo Corporation.. Character Set “Neutral” “ISO8859_1” “ISO8859_2” “ISO8859_3” “ISO8859_4” “ISO8859_5” “ISO8859_6” Comments No character conversions performed. can incorporate optional CharSet clauses. Windows) using only one character set.

Windows Eastern Europe Comments Windows Traditional Chinese Windows Simplified Chinese Reference Guide © 2006 MapInfo Corporation.CharSet clause Character Set “ISO8859_7” “ISO8859_8” “ISO8859_9” “PackedEUCJapanese” “WindowsLatin2” “WindowsArabic” “WindowsCyrillic” “WindowsGreek” “WindowsHebrew” “WindowsTurkish” “WindowsTradChinese” “WindowsSimpChinese” “WindowsJapanese” “WindowsKorean” “CodePage437” “CodePage850” “CodePage852” “CodePage855” “CodePage857” “CodePage860” “CodePage861” “CodePage863” “CodePage864” “CodePage865” “CodePage869” “LICS” “LMBCS” DOS Code Page 860 = Portuguese DOS Code Page 861 = Icelandic DOS Code Page 863 = French Canadian DOS Code Page 864 = Arabic DOS Code Page 865 = Nordic DOS Code Page 869 = Modern Greek Lotus worksheet release 1. All rights reserved.4 character set DOS Code Page 437 = IBM Extended ASCII DOS Code Page 850 = Multilingual DOS Code Page 852 = Eastern Europe DOS Code Page 855 = Cyrillic ISO 8859-7 (UNIX) ISO 8859-8 (UNIX) ISO 8859-9 (UNIX) UNIX. 127 .2 character set Lotus worksheet release 3. standard Japanese implementation.

CharSet “MAC” specifies the same character set as CharSet “MacRoman”. “ANSI” and “MAC”. then the default Longitude/Latitude coordinate system is used as the initial selection. however.ChooseProjection$( ) function Note: You never need to specify a CharSet clause in an Open Table statement.x CharSet Syntax MapBasic version 2. If initial_coordsys is empty or an invalid CoordSys clause.TAB file contains information about the character set used by the table. get_bounds ) initial_coordsys is a string value in the form of a CoordSys clause. Create Table statement.x supported three character sets: “XASCII”. get_bounds is a logical value that determines whether the users is prompted for boundary values when a non-earth projection is selected. 128 © 2006 MapInfo Corporation. MapInfo Professional reads the character set information directly from the . MapBasic 8. If get_bounds is true then the boundary dialog box is displayed.txt" For INPUT As #1 CharSet "CodePage437" See Also Commit Table statement. To force MapInfo Professional to save a table in a specific character set. Open File statement. Example: When reading a file created by a DOS application. include a CharSet clause in the Commit Table statement. If false. It is used to set which coordinate system is selected when the dialog box is first displayed. MapBasic 2. Syntax ChooseProjection$( initial_coordsys. you should specify the “CodePage437” character set. Open File "parcel. then automatically performs any necessary character translations. Older programs that refer to those three character-set names will still compile and run in later versions of MapBasic. Each table's .5 .TAB file. then the dialog box is not displayed and the default boundary is used. CharSet “ANSI” specifies whatever character set Windows is currently using. When a program runs on Windows. as shown in the following example. When opening a table. continued use of the 2.x-era character set names is discouraged. Register Table statement ChooseProjection$( ) function Purpose Displays the Choose Projection dialog box and returns the coordinate system selected by the user. Export statement. All rights reserved. CharSet “XASCII” specifies the same character set as CharSet “CodePage437”.

Note: All MapInfo Professional environments have common character codes within the range of 32 (space) to 126 (tilde).535. Character 12 is the form-feed character. 129 . num_expr should be a positive integer value between 0 and 255. Character 34 is the double-quotation mark ("). one character long. 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.. you can use the statement Print Chr$(12) to clear the Message window. Thus. Syntax Chr$( num_expr ) num_expr is an integer value from 0 to 255 (or. True) strNewCoordSys = "Set " + strNewCoordSys Run Command strNewCoordSys See Also MapperInfo( ) function Chr$( ) function Purpose Returns a one-character string corresponding to a specified character code. Character 10 is the line-feed character. num_expr can have a value from 0 to 65. If a string expression includes the function call Chr$(34). MapBasic rounds to the nearest integer. inclusive. Example Dim strNewCoordSys As String strNewCoordSys = ChooseProjection$( "". On most systems. If the num_expr parameter is fractional. Windows Japanese).g. On systems that support double-byte character sets (e.535). see example below. from 0 to 65. Reference Guide © 2006 MapInfo Corporation. if a double-byte character set is in use. based on the character code specified in the num_expr parameter. MapBasic embeds a double-quote character in the string. Return Value String Description The Chr$( ) function returns a string.Chr$( ) function Description This function displays the Choose Projection dialog box and returns the selected coordinate system as a string. All rights reserved.

Close All statement Error Conditions The ERR_FCN_ARG_RANGE error is generated if an argument is outside of the valid range." See Also Asc( ) function Close All statement Purpose Closes all open tables.5 . See Also Close Table statement Close Connection statement Purpose Closes a connection opened with the Open Connection statement. MapBasic 8. Syntax Close All [ Interactive ] Description If a MapBasic application issues a Close All statement. All rights reserved. and the affected table has edits pending (the table has been modified but the modifications have not yet been saved to disk). Syntax Close Connection connection_handle connection_handle is an integer expression representing the value returned from the Open Connection statement. Example Dim s_letter As String * 1 s_letter = Chr$(65) Note s_letter ' This displays the letter "A" Note "This message spans" + Chr$(10) + "two lines. If you do not want to discard pending edits. No warning will be displayed. use the optional Interactive clause to prompt the user to save or discard changes. the edits will be discarded before the table is closed. 130 © 2006 MapInfo Corporation.

.Close File statement Description The Close Connection statement closes the specified connection using the connection handle that is returned from an Open Connection statement. then. See Also Open Connection statement Close File statement Purpose Closes an open file. Syntax Close File [ # ] filenum filenum is an integer number identifying which file to close. 131 . Note: The Open File statement and Close File statement operate on files in general. Any service specific properties associated with the connection are lost. MapBasic provides a separate set of statements (e.g.txt" For INPUT As #1 ' ' read from the file.. Example Open File "cxdata. when done: ' Close File #1 See Also Open File statement Close Table statement Purpose Closes an open table. Open Table statement) for manipulating MapInfo tables. not on MapInfo Professional tables. Description The Close File statement closes a file which was opened through the Open File statement. Syntax Close Table table [ Interactive ] Reference Guide © 2006 MapInfo Corporation.. All rights reserved.

Close Table Selection See Also Close All statement. TAB_INFO_EDITED) function. the window closes. If a table is displayed in one or more Grapher or Browser windows. if such prompts are appropriate. when done using the WORLD table. use the Close All statement. To guarantee that pending edits are saved.Close Table statement table is the name of a table that is open Description The Close Table statement closes an open table. Commit Table statement. If you include the Interactive keyword. To prompt the user to save themes or cosmetic objects..) Examples Open Table "world" ' . TableInfo( ) function 132 © 2006 MapInfo Corporation. any unsaved edits are discarded. and if the table has unsaved edits. Open Table statement. (The user is not prompted if the window has no themes or cosmetic objects. issue a Commit Table statement before the Close Table statement. If you omit the Interactive keyword. Saving Themes and Cosmetic Objects When you close the last table in a Map window. To determine whether a table has unsaved edits. the user may want to save thematic layers or cosmetic objects before closing the window. omit the Interactive keyword or issue a Rollback statement before calling Close Table. close the Selection table. MapBasic closes the table regardless of whether the table has unsaved edits.5 . MapBasic displays a dialog box allowing the user to save or discard the edits or cancel the close operation. ' close it by saying: Close Table world To deselect the selected rows. If you include the Interactive keyword. If you use the Close Table statement to close a linked table that has edits pending. To guarantee that pending edits are discarded. If the Close Table statement closes the only table in a Map window. the Close Table statement will not prompt the user to save themes or cosmetic objects. However. those windows disappear automatically when the table is closed. To close all tables. Rollback statement. Saving Edits If you omit the optional Interactive keyword. the window closes. MapBasic 8.. include the Interactive keyword. call the TableInfo( table. MapInfo Professional keeps the edits pending until a later session. dialog boxes will prompt the user to save themes and/or cosmetic objects. All rights reserved.

You can obtain integer window identifiers through the FrontWindow( ) function and the WindowID( ) function.. Its define code: WIN_MESSAGE.. a window code (e. The Theme Legend window. Browse. Graph. To close a document window (Map. The Help window.. Help Statistics Legend Info Ruler Message Saving Themes and Cosmetic Objects The user may want to save thematic layers or cosmetic objects before closing the window. Syntax Close Window window_spec [ Interactive ] window_spec is a window name (e. To close a special MapInfo Professional window.g. Ruler) or by code (e.. The Ruler tool window. specify an integer window identifier as the window_spec parameter. Ruler). To prompt the user to save themes or cosmetic objects. WIN_RULER). or Layout). The Info tool window. specify one of the window names from the table below as the window_spec parameter. Its define code: WIN_INFO. Description The Close Window statement closes or hides a MapInfo Professional window. Its define code: WIN_RULER. Its define code: WIN_HELP. Reference Guide © 2006 MapInfo Corporation. 133 .g. Its define code: WIN_STATISTICS. include the Interactive keyword. WIN_RULER). The Message window (which appears when you issue a Print statement). You can also refer to this window by its define code: WIN_MAPBASIC.g. All rights reserved. You can identify a special window by name (e.Close Window statement Close Window statement Purpose Closes or hides a window. or an integer window identifier. Its define code: WIN_LEGEND.g. The Statistics window. The following table lists the available window_spec values: window_spec value MapBasic Window description The MapBasic window.

Return Value Depends on the attribute parameter specified. The function's first parameter specifies either the name or the number of an open table. SmallInt indicating the number of the column. n is the number of a column in the table. columnname is the name of a column in that table. Syntax ColumnInfo( { tablename | tablenum } . The attribute parameter can be any value from this table. All rights reserved. The second parameter specifies which column to query.ColumnInfo( ) function If you omit the Interactive keyword. SmallInt indicating the column type (see table below). attribute ) tablename is a string representing the name of an open table. MapBasic 8. If you include the Interactive keyword. Print statement. tablenum is an integer representing the number of an open table.) Example Close Window Legend See Also Open Window statement. attribute is a code indicating which aspect of the column to read. attribute setting COL_INFO_NAME COL_INFO_NUM COL_INFO_TYPE ColumnInfo( ) returns: String identifying the column name. if such prompts are appropriate. the Close Window statement will not prompt the user to save themes or cosmetic objects. Description The ColumnInfo( ) function returns information about one column in an open table. 134 © 2006 MapInfo Corporation. Set Window statement ColumnInfo( ) function Purpose Returns information about a column in an open table. dialog boxes will prompt the user to save themes and/or cosmetic objects. The attribute parameter dictates which of the column's attributes the function should return. (The user will not be prompted if the window has no themes or cosmetic objects.5 . { columnname | "COLn"} .

COL_INFO_TYPE) Reference Guide © 2006 MapInfo Corporation.DEF" Dim s_col_name As String. Date. Your program must Include “MAPBASIC.DEF. this represents the graphical objects attached to the table.DEF” if you intend to reference these codes. SmallInt indicating the number of decimal places in a Decimal column.ColumnInfo( ) function attribute setting COL_INFO_WIDTH ColumnInfo( ) returns: SmallInt indicating the column width. The codes listed in both of the above tables are defined in the standard MapBasic definitions file. 135 . applies to Character or Decimal columns only. ERR_FCN_ARG_RANGE error generated if an argument is outside of the valid range. Small integer (2-byte). special column type Obj. i_col_type As SmallInt Open Table "world" s_col_name = ColumnInfo("world"."col1". Logical value indicating if column is indexed. MapBasic returns one of the values from the table below: ColumnInfo( ) returns: COL_TYPE_CHAR COL_TYPE_DECIMAL COL_TYPE_FLOAT COL_TYPE_INTEGER COL_TYPE_SmallInt COL_TYPE_DATE COL_TYPE_LOGICAL COL_TYPE_GRAPHIC Character. Floating-point decimal. Error Conditions ERR_TABLE_NOT_FOUND error generated if the specified table is not available. Type of column indicated: Fixed-point decimal.COL_INFO_NAME) i_col_type = ColumnInfo("world". COL_INFO_DECPLACES COL_INFO_INDEXED COL_INFO_EDITABLE If the ColumnInfo( ) function call specifies COL_INFO_TYPE as its attribute parameter."col1". Integer (4-byte). Logical value indicating if column is editable. Logical (TRUE or FALSE). MAPBASIC. All rights reserved. Example Include "MAPBASIC.

Linear. Polyline. The following table details the possible combine options available and the output results: Input Object Type Point or MultiPoint Linear (Line. TableInfo( ) function Combine( ) function Purpose Returns a region or polyline representing the union of two objects. MultiPoint.5 . Syntax Combine( object1. Arc) Closed (Region. a region and a circle).. Polylines. or both objects can be linear (e. or Arcs) and produce Polylines as output. Previously. Text objects are still not allowed as input to Combine( ).. and Collections as input objects. Rectangle. The union of two objects represents the entire area that is covered by either object. MultiPoint. The Combine( ) function has been updated to allow heterogeneous combines. a line and a polyline) Return Value An object that is the union of object1 and object2. extend the Combine operation. both objects had to be either linear objects (Lines. object2 are two object expressions. Closed.Combine( ) function See Also NumCols( ) function. both objects can be closed (e. MultiPoint and Collection objects. MapBasic 8. MultiPoint and Collection objects. Rectangles. MultiPoints. All rights reserved. Closed. Rounded Rectangles. or Ellipses) and produce Regions as output. or both input objects had to be closed (Regions. Linear. as are combines containing Point.5. Collection Input Object Type Point or MultiPoint Linear Closed OutputObject Type MultiPoint Polyline Region Point. introduced in MapInfo Professional 6. Rounded Rectangle. and to allow Points.g.g. Description The Combine( ) function returns an object representing the geographical union of two object expressions. The objects cannot be Text objects. Collection Collection 136 © 2006 MapInfo Corporation. Heterogeneous combines are not allowed. Ellipse) Point. object2 ) object1.

See Also Objects Combine statement CommandInfo( ) function Purpose Returns information about recent events. Return Value Logical. or string. and the remaining portions of style from objects2. All rights reserved. whether the “Selection” table has changed. the Combine( ) function does not alter the object1 or object2 expressions. or whether it was a simple click or a “shift click.” Reference Guide © 2006 MapInfo Corporation.. if object1 is a Region and object2 is a Polyline. where the user clicked with the mouse. Description The CommandInfo( ) function returns information about recent events that affect MapInfo Professional—for example. float. For example. color) of the object1 parameter when possible. except that the Combine menu item modifies the original objects. and the pen from object2 for the Polyline style in the collection.g.CommandInfo( ) function The results returned by Combine( ) are similar to the results obtained by choosing MapInfo Professional's Objects > Combine menu item. depending on circumstances. integer. then the output collection will use the brush and boarder pen of object1 for the Region style contained in the collection. the Combine( ) function does not perform data aggregation. Syntax CommandInfo( attribute ) attribute is an integer code indicating what type of information to return. Collection objects produced as output will get those portions of style that are possible from object1. 137 . Also. The object returned by the Combine( ) function retains the styles (e.

MapBasic 8. CMD_INFO_STATUS Within a Custom Menu or Dialog Handler When you call CommandInfo( ) from within the handler procedure for a custom menu command or a custom dialog box. 3 if multiple rows were added to the selection. RemoteMsgHandler procedure. This call is only valid within the handler procedure of a custom menu item. 4 if multiple rows were de-selected. representing the ID of the menu item the user chose.) Logical value: TRUE if the user allowed a progress-bar operation to complete. (This call is only valid following a Dialog statement. 2 if one row was removed from the selection. or FALSE if the user pressed the Cancel button to halt. the attribute parameter can be any of the codes from the following table. CMD_INFO_DLG_DBL Within a Standard Handler Procedure When you call CommandInfo( ) from within a standard system handler procedure (such as SelChangedHandler). Logical value: TRUE if the user double-clicked on a ListBox or MultiListBox control within a custom dialog box.CommandInfo( ) function After Displaying a Dialog Box When you call CommandInfo( ) after displaying a custom dialog box. WinChangedHandler and WinClosedHandler. For details.5 . the attribute parameter can be one of these codes: attribute code CMD_INFO_MENUITEM CommandInfo( attribute ) returns: Integer value. This call is only valid within the handler procedure of a custom dialog box. From within SelChangedHandler: attribute code CMD_INFO_SELTYPE CommandInfo( attribute ) returns: 1 if one row was added to the selection. pressing Esc. All rights reserved. FALSE if user canceled by clicking Cancel. see the separate discussions of SelChangedHandler. 138 © 2006 MapInfo Corporation. the attribute parameter can be one of these codes: attribute code CMD_INFO_DLG_OK CommandInfo( attribute ) returns: Logical value: TRUE if the user dismissed a custom dialog box by clicking OK. etc.

RemoteQueryHandler( ) function. All rights reserved. representing the ID of the window that changed or the window that closed. or RemoteMapGenHandler procedure. indicating whether MapInfo Professional just became the active application or just stopped being the active application.CommandInfo( ) function attribute code CMD_INFO_ROWID CommandInfo( attribute ) returns: Integer value: The number of the row that was selected or deselected (only applies if a single row was selected or deselected). From within ForegroundTaskSwitchHandler procedure: attribute code CMD_INFO_TASK_SWITCH CommandInfo( attribute ) returns: Integer value. From within WinChangedHandler procedure or WinClosedHandler procedure: attribute code CMD_INFO_WIN CommandInfo( attribute ) returns: Integer value. the RemoteQueryHandler( ) function. representing the execute string or the item name sent to MapInfo Professional by a client program. 139 . The return value matches one of these codes: SWITCHING_INTO_MI Pro (If MapInfo Professional received the focus) SWITCHING_OUT_OF_MapInfo Professional (If MapInfo Professional lost the focus). For details. Reference Guide © 2006 MapInfo Corporation. or the RemoteMapGenHandler procedure: attribute code CMD_INFO_MSG CommandInfo( attribute ) returns: String value. Logical value: TRUE if the user interrupted a selection by pressing Esc. see RemoteMsgHandler procedure. FALSE otherwise. see WinChangedHandler procedure or WinClosedHandler procedure. CMD_INFO_INTERRUPT From within the RemoteMsgHandler procedure. For details.

CMD_INFO_Y2 140 © 2006 MapInfo Corporation. indicating whether the Find statement found a match. indicating the Row ID number of the row that was found.g. DM_CUSTOM_LINE. indicating x. • CMD_INFO_X2 x-coordinate of the spot where the user released the mouse button. • • CMD_INFO_Y y-coordinate of the spot where the user clicked: • • If the user clicked on a map. If the user clicked on a Browser.g. the value represents a row number.CommandInfo( ) function After a Find Operation Following a Find statement. or zero for the select-box column).g.g.. one for the leftmost column. longitude). the value represents the distance from the left edge of the Layout (e. Latitude). and a value of zero represents the row of column headers at the top of the window. e. in the current coordinate system unit. If the user clicked on a Layout. the return value represents a map coordinate (e. y-coordinate of the spot where the user released the mouse button. the value represents the distance from the top edge of the Layout. MapBasic 8. CMD_INFO_FIND_ROWID CMD_INFO_X or CMD_INFO_Y Within a Custom ToolButton's Handler Procedure Within a custom ToolHandler procedure. zero represents the left edge). Floating-point number. the value represents a map coordinate (e. in MapBasic's current paper units. If the user clicked on a Browser. If the user clicked in a Layout. the value represents the number of a column in the Browser (e...or y-coordinates of the location that was found. a value of one represents the top row..g. you can specify any of these codes: attribute code CMD_INFO_X CommandInfo( attribute ) returns: x coordinate of the spot where the user clicked: • If the user clicked on a Map.. Integer value.5 . the attribute parameter can be one of these codes: attribute code CMD_INFO_FIND_RC CommandInfo( attribute ) returns: Integer value. All rights reserved. This only applies if the toolbutton was defined with a draw mode that allows dragging.

Logical value: TRUE if the user held down the Ctrl key while clicking. ID of the table row corresponding to the map object or browser row. Set Command Info statement. 141 . All rights reserved. Layer ID. CMD_INFO_CTRL CMD_INFO_TOOLBTN CMD_INFO_CUSTOM_OBJ Hotlink Support MapBasic applications launched via the Hotlink Tool can use the CommandInfo( ) function to obtain information about the object that was activated. CMD_INFO_HL_LAYER_ID CMD_INFO_HL_FILE_NAME See Also FrontWindow( ) function. Object value: a polyline or polygon drawn by the user. WindowInfo( ) function Reference Guide © 2006 MapInfo Corporation. Name of table associated with the map layer or browser. representing the ID of the button the user clicked. if the program was launched from a map window. SelectionInfo( ) function. Applies to drawing modes DM_CUSTOM_POLYLINE or DM_CUSTOM_POLYGON.CommandInfo( ) function attribute code CMD_INFO_SHIFT CommandInfo( attribute ) returns: Logical value: TRUE if the user held down the Shift key while clicking. Integer value. Name of file launched. The following is a table of the attributes that can be queried: attribute code CMD_INFO_HL_WINDOW_ID CMD_INFO_HL_TABLE_NAME CMD_INFO_HL_ROWID CommandInfo( attribute ) returns: ID of map or browser window.

version is 100 (to create a table that can be read by versions of MapInfo Professional) or 300 (MapInfo Professional 3. ConnectionNumber is an integer value that identifies the specific connection to a database. Acceptable values are 4. If the database in which the table is being created already exists.TAB file is saved.0 format) for non-Access tables. char_set is the name of a character set. tablename is a string that indicates the name of the table as it will appear in Access. All rights reserved. commit_keyword is one of the following keywords: NoCollision. ] [ Version version ] ] [ { Interactive | Automatic commit_keyword } ] [ConvertObjects { ON | OFF | INTERACTIVE }] table is the name of the table you are saving. version is an expression that specifies the version of the Microsoft Jet database format to be used by the new database. Syntax Commit Table table [ As filespec [ Type { NATIVE | DBF [ Charset char_set ] | Access Database database_filespec [ Version version ] Table tablename [ Password pwd ] [ Charset char_set ] | QUERY } ] ODBC Connection ConnectionNumber Table tablename [ CoordSys. MapBasic 8.5 . DiscardUpdates 142 © 2006 MapInfo Corporation.0 (for Access '95/'97).Commit Table statement Commit Table statement Purpose Saves recent edits to disk.MDB file. ApplyUpdates. If the specified database does not exist. If omitted. filespec is a file specification (optionally including directory path). or saves a copy of a table. pwd is the database-level password for the database. database_filespec is a string that identifies the name and path of a valid Access database.0 (for Access 2000) or 3.0.. This is where the MapInfo . MapInfo Professional creates a new Access . to be specified when database security is turned on. For Access tables. ODBC indicates a copy of the Table will be saved on the DBMS specified by ConnectionNumber. the specified database version is ignored. tablename is the name of the table as you want it to appear in the database. the default version is 4. version is 410.. see CoordSys clause on page 161. CoordSys is a coordinate system clause. see CharSet clause on page 125.

MapInfo Professional warns the user about the loss of the memo fields. A Commit Table statement that includes an As clause has the same effect as a user choosing File > Save Copy As. The CharSet clause specifies a character set. file type. If you specify Version 100. MapInfo Professional stores the table in a format readable by versions of MapInfo Professional. No warning will be displayed. If you specify Version 300. specify the new name in the filespec string. (These clauses have no effect on saving a conventional MapInfo table.TAB file and a . include a CoordSys clause within the As clause. See CharSet clause on page 125 for more information. Saving Linked Tables Saving a linked table can generate a conflict. To save the table in a new directory path. when the table is saved to a new table name through a MapBasic program. directory. MapInfo Professional stores the table in MapInfo Professional 3. After a successful Commit Table Interactive statement. However.000 nodes and multiple-segment polyline objects require version 300. To save the table using a new file type. Only queries made from the user interface and queries created from Run Command statements in MapBasic can be saved.QRY file. 143 . MapInfo Professional displays a dialog box allowing the user to refresh. To save a Query use the QUERY type for the table. To save the table using a different coordinate system or projection.0 format. but can also be saved as DBF. MapInfo Professional displays the Conflict Resolution dialog box. include a Type clause within the As clause. such as “WindowsLatin1”. If you omit the Version clause. the table is saved in the version 300 format. the memo fields will not be retained in the new table. The As clause can be used to save the table with a different name. All rights reserved. Note: If a MapBasic application issues a Commit Table…As statement affecting a table which has memo fields. Reference Guide © 2006 MapInfo Corporation. By default.) Interactive In the event of a conflict. If no CharSet clause is specified. If the table is saved to a new table through MapInfo Professional's user interface (by choosing File > Save Copy As).Commit Table statement Description If no As clause is specified. specify the directory path at the start of the filespec string. or projection. The Version clause controls the table's format. The char_set parameter should be a string constant. the type of the new table is NATIVE. Note that only a mappable table may have a coordinate system or a projection. the Commit Table statement saves any pending edits to the table. no warning appears. The following clauses let you control what happens when there is a conflict. The Commit Table statement creates a . MapBasic uses the default character set for the hardware platform that is in use at runtime. Note that region and polyline objects having more than 8. when another user may have edits the same data in the same table MapInfo Professional will detect if there were any conflicts and allows the user to resolve them. This is analogous to the user choosing File > Save. To save the table under a new name.

If the As clause is used and ODBC is the Type. however. (including saving a point-only table) the SpatialWare/Blade is required for SQL Server and IUS. We recommend 14 or fewer characters for a table name in order to work correctly for all databases. The supported databases include Oracle. Unsupported object types will not be saved to the destination table. may be added to the database table. in addition to the spatial option for Oracle. Example The following example opens the table STATES. ODBC Connection The length of tablename varies with databases. The XY schema is not supported in this statement. 0. 20. SQL Server. (This is the default behavior if the statement does not include an Interactive clause or an Automatic clause. IIS (Informix Universal Server). 0. If the source table is not mappable. The statement limits the length of the tablename to a maximum of 31 characters. The optional CoordSys clause causes the ALBERS table to be saved using the Albers equal-area projection.) Automatic DiscardUpdates In the event of a conflict. A spatial index will be created on the Object column if one is present. 60. and Style column. tablename. MapInfo Professional saves the local updates. but the rest of the attributes will be saved. MapInfo Professional saves the local updates already in the RDBMS (discards your local updates). However. the new copy is not a linked table and no changes are updated to the server. The Key column will be used to create a unique index. may be added to the destination database table. All rights reserved. whether or not the source table has those columns. "m".5 . to save a table with a spatial geometry/object. Key column. (This is analogous to ignoring conflicts entirely. Open Table "STATES" Commit Table STATES As "ALBERS" CoordSys Earth Projection 9.0 The following example illustrates an ODBC connection: dim hodbc as integer hodbc = server_connect("ODBC". then uses the Commit Table statement to make a copy of the states table under a new name (ALBERS).0. 23. MapInfo Professional does not perform the save. MapBasic 8. Object column. one more column.) Automatic ApplyUpdates In the event of a conflict.0.0.Commit Table statement Automatic NoCollision In the event of a conflict. a copy of the table will be saved on the database specified by ConnectionNumber and named as tablename. even if the source table does not have a Key column. If the source table is mappable. "dlg=1") 144 © 2006 MapInfo Corporation.0. -96. three more columns.7. Key column. tablename. You can copy a linked table by using the As clause.0. and Microsoft Access.

Return Value This statement returns a single section. ConnectObjects( ) returns a Polyline object connecting object1 and object2 in the shortest (min == TRUE) or longest (min == FALSE) way using a spherical calculation method. two-point Polyline object representing either the closest distance (min == TRUE) or farthest distance (min == FALSE) between object1 and object2.ConnectObjects( ) function Open table "C:\MapInfo\USA" Commit Table USA as "c:\temp\as\USA" Type ODBC Connection hodbc Table "USA" See Also Rollback statement ConnectObjects( ) function Purpose Returns an object representing the shortest or longest distance between two objects. min ) object1 and object2 are object expressions. Description One point of the resulting Polyline object is on object1 and the other point is on object2. object2. if the MapBasic coordinate system is NonEarth). Syntax ConnectObjects( object1.g. and FALSE calculates the maximum distance between objects.. then a Cartesian method will be used. Continue statement Purpose Resumes the execution of a MapBasic program (following a Stop statement). min is a logical expression where TRUE calculates the minimum distance between the objects. 145 .g. All rights reserved. Note that the distance between the two input objects can be calculated using the ObjectLen( ) function.. If the calculation cannot be done using a spherical distance method (e. There is no way to determine if the object returned is uniquely the shortest distance. 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. If there are multiple instances where the minimum or maximum distance exists (e. Syntax Continue Reference Guide © 2006 MapInfo Corporation.

y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Calling handler ] [ Title title_string ] [ Disable ] [ Hide ] x. h specifies the height of the button in dialog box units. it may not be included as part of a compiled program. You can include Stop statements in a program for debugging purposes. cannot be the same as the ID of another control in the dialog box.5 . control_ID is an integer. adds a push-button control to a dialog box. Each dialog box should have no more than one OKButton control. If the OKButton keyword appears in place of the Button keyword. When a MapBasic program encounters a Stop statement. Description The Continue statement resumes the execution of a MapBasic application which was suspended because of a Stop statement. y specifies the button's position in dialog box units. MapBasic 8. the dialog box includes a push-button control. and the File menu automatically changes to include a Continue Program option instead of a Run option. Control Button / OKButton / CancelButton clause Purpose Part of a Dialog statement. default height is 18.Control Button / OKButton / CancelButton clause Restrictions The Continue statement may only be issued from the MapBasic window. All rights reserved. You can resume the suspended application by choosing File > Continue Program. Syntax Control { Button | OKButton | CancelButton } [ Position x. the user chooses a CancelButton control to “choose Cancel” and dismiss the dialog box. Typing the Continue statement into the MapBasic window has the same effect as choosing Continue Program. and have no more than one CancelButton control. w specifies the width of the button in dialog box units. 146 © 2006 MapInfo Corporation. the user chooses an OKButton control to “choose OK” and dismiss the dialog box. the program is suspended. Description If a Dialog statement includes a Control Button clause. handler is the name of a procedure to call if the user clicks on the button. Hide makes the control hidden initially. the control is a special type of button. default width is 40. Disable makes the control disabled (grayed out) initially. Similarly. title_string is a text string to appear on the button.

whether the control is enabled or hidden). All rights reserved. Description If a Dialog statement includes a Control CheckBox clause. 190 See Also Alter Control statement. Dialog statement Control CheckBox clause Purpose Part of a Dialog statement. cannot be the same as the ID of another control in the dialog box. Hide makes the control hidden initially. log_variable is the name of a logical variable. log_value is a logical value: FALSE sets the control to appear un-checked initially. w specifies the width of the control in dialog box units. y ] [ Width w ] [ ID control_ID ] [ Calling handler ] [ Title title_string ] [ Value log_value ] [ Into log_variable ] [ Disable ] [ Hide ] x. If the Value clause specifies a FALSE value. Disable makes the control disabled (grayed out) initially. or if it specifies a value of TRUE. adds a check box control to a dialog box Syntax Control CheckBox [ Position x.Control CheckBox clause Use the Alter Control statement to change a control's status (e. control_ID is an integer. Reference Guide © 2006 MapInfo Corporation. check-box is clear initially. handler is the name of a procedure to call if the user clicks on the control. The Value clause controls the initial appearance. title_string is a text string to appear in the label to the right of the check-box. Example Control Button Title "&Reset" Calling reset_sub Position 10. the dialog box includes a check-box control. the check-box is checked initially. If the Value clause is omitted. 147 .g.. y specifies the control's position in dialog box units.

155 See Also Alter Control statement. control_ID is an integer. h specifies the height of the control in dialog units. ReadControlValue( ) function Control DocumentWindow clause Purpose Part of a Dialog statement. All rights reserved. MapBasic 8. the dialog box includes a document window control that can be re-parented using the Set Next Document statement.5 . Description If a Dialog statement includes a Control DocumentWindow clause. default width is 100. y specifies the control's position in dialog box units. y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Disable ] [ Hide ] x. Hide initially hides the control. cannot be the same as the ID of another control in the dialog box.Control DocumentWindow clause Example Control CheckBox Title "Include &Legend" Into showlegend ID 6 Position 115. default height is 100. Dialog statement. w specifies the width of the control in dialog units. adds a document window control to a dialog box which can be re-parented for integrated mapping. Syntax Control DocumentWindow [ Position x. Disable grays out the control initially. 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: 148 © 2006 MapInfo Corporation.

Control DocumentWindow clause 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 Reference Guide © 2006 MapInfo Corporation. All rights reserved. 149 .

variable is the name of a string variable or a numeric variable.767 characters. if the height is greater than 20. w specifies the width of the control in dialog box units. MapInfo Professional automatically wraps text down to successive lines as the user types. initial_value is a string or a numeric expression that initially appears in the dialog box. To make an EditText control the active control. An EditText control can hold up to 32. MapInfo Professional automatically scrolls the text to make room. if the height is larger than 20). the string associated with the EditText control will contain a Chr$(10) value at the location of each line-feed. 150 © 2006 MapInfo Corporation. The Disable keyword makes the control disabled (grayed out) initially. The Password keyword creates a password field.Control EditText clause Control EditText clause Purpose Part of a Dialog statement. MapBasic 8. use an Alter Control…Active statement. All rights reserved. the text appears formatted when the dialog box appears. MapInfo Professional stores the final value of the field in the variable if the user clicks OK. If the user enters a line-feed into the EditText box (for example. which displays asterisks as the user types. If the height is large enough to fit two or more lines of text (for example. Description If the user types more text than can fit in the box at one time. Syntax Control EditText [ Position x. on Windows. control_ID is an integer. y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Value initial_value ] [ Into variable ] [ Disable ] [ Hide ] [ Password ] x. the control becomes a multiple-line control. If the initial_value expression contains embedded Chr$(10) values. if the user presses CtrlEnter while in the EditText box).5 . The Hide keyword makes the control hidden initially. cannot be the same as the ID of another control in the dialog box. h specifies the height of the control in dialog box units. adds an EditText control box (input text) to a dialog box. and text wraps down onto successive lines. y specifies the control's position in dialog box units.

30 Height 40 Width 70 See Also Alter Control statement. cannot be the same as the ID of another control in the dialog box. adds a rectangle with a label to a dialog box. control_ID is an integer. 8 Width 90 ID 1 Into s_map_title See Also Alter Control statement. Dialog statement Reference Guide © 2006 MapInfo Corporation. Syntax Control GroupBox [ Position x. h specifies the height of the control in dialog box units. 151 . All rights reserved.Control GroupBox clause Example Control EditText Value "Franchise Locations" Position 65. w specifies the width of the control in dialog box units. y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Title title_string ] [ Hide ] x. y specifies the control's position in dialog box units. title_string is a text string to appear at the upper-left corner of the box The Hide keyword makes the control hidden initially. ReadControlValue( ) function Control GroupBox clause Purpose Part of a Dialog statement. Dialog statement. Example Control GroupBox Title "Level of Detail" Position 5.

Control ListBox / MultiListBox clause Control ListBox / MultiListBox clause Purpose Part of a Dialog statement. A MultiListBox control is identical to a ListBox control. default width is 80. w specifies the width of the control in dialog box units.4th Quarter" 152 © 2006 MapInfo Corporation. each item appears as one item in the list.2nd Quarter. i_variable is the name of a SmallInt variable which stores the user's final selection. cannot be the same as the ID of another control in the dialog box. The Title clause specifies the contents of the list. containing a semicolon-delimited list of items to appear in the control. The Disable keyword makes the control disabled (grayed out) initially. except that the user can shift-click to select multiple items from a MultiListBox control.3rd Quarter. If the list contains more items than can be shown in the control at one time. handler is the name of a procedure to call if the user clicks or double-clicks on the list. adds a list to a dialog box Syntax Control { ListBox | MultiListBox } [ Position x. the dialog box includes a listbox control. h specifies the height of the control in dialog box units. The Hide keyword makes the control hidden initially. The following sample Title clause demonstrates this syntax: Title "1st Quarter. MapBasic automatically adds a scroll-bar at the right side of the control. MapBasic 8.5 . All rights reserved. str_array_var is the name of an array of string variables. control_ID is an integer. y specifies the control's position in dialog box units. str_expr is a string expression. no items are selected initially. If the Title clause specifies a string expression containing a semicolon-delimited list of items. Description If a Dialog statement includes a Control ListBox clause. y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Calling handler ] [ Title { str_expr | From Variable str_array_var } ] [ Value i_selected ] [ Into i_variable ] [ Disable ] [ Hide ] x. default height is 70. i_selected is a SmallInt value indicating which list item should appear selected when the dialog box first appears: a value of one selects the first list item. if the clause is omitted.

you may want to dismiss the dialog box as if the user had clicked on a list item and then clicked OK. All rights reserved.. If the first call to the ReadControlValue( ) function returns zero.3rd Quarter. i = ReadControlValue( TriggerControl( ) ) Dialog Remove ' at this point.MB in <Your MapBasic Installation Directory>\SAMPLES\MAPBASIC\SNIPPETS. End If End Sub Example Control ListBox Title "1st Quarter. assign a handler procedure that is called when the user dismisses the dialog box (for example.Control ListBox / MultiListBox clause Alternately. set up a loop to call the ReadControlValue( ) function repeatedly.2nd Quarter. When the ReadControlValue( ) function returns zero. etc. each entry in the array appears as one item in the list. MapBasic calls the procedure every time the user clicks or double-clicks an item in the list. when the user double-clicks a list item. In some cases. there are no list items selected.4th Quarter" ID 3 Value 1 Into i_quarter Position 10. To determine whether the user clicked or double-clicked.. you may want to provide special handling for double-click events. Within the handler procedure. The first call to the ReadControlValue( ) function returns the number of the first selected item. as shown in the following sample handler procedure: Sub lb_handler Dim i As SmallInt If CommandInfo(CMD_INFO_DLG_DBL) Then ' . The following sample Title clause demonstrates this syntax: Title From Variable s_optionlist Processing a MultiListBox control To read what items the user selected from a MultiListBox control. the variable i represents ' the selected list item. then the user double-clicked. you have exhausted the list of selected items. 153 . call the CommandInfo( ) function within the list control's handler procedure... if the Title clause specifies an array of string variables. the second call to the ReadControlValue( ) function returns the number of the second selected item. Processing Double-click events If you assign a handler procedure to a list control. 92 Height 40 Reference Guide © 2006 MapInfo Corporation. To see an example. assign a handler to the OKButton control). For example. refer to the sample application NVIEWS.

MapBasic calls the sub procedure “listbox_ handler. Alter Control 2 Enable Alter Control 3 Enable If CommandInfo(CMD_INFO_DLG_DBL) = TRUE Then ' . i = ReadControlValue(1) ' read user's choice. “listbox_handler. To complete the dialog box. the dialog box would remain on the screen until the user clicked OK or Cancel. The handler procedure must check to determine whether the event was a single. ReadControlValue( ) function.then the user DOUBLE-clicked. All rights reserved.” Control ListBox Title desc_list ID 1 Position 10.5 . MapBasic 8. Note that the ListBox control has a handler routine. ' we can enable the OK button and the Delete button. End If End Sub MapBasic calls the handler procedure whether the user clicks or double-clicks. the procedure issues a Dialog Remove statement to dismiss the dialog box.MB sample program demonstrates how to create a dialog box which provides special handling for when the user double-clicks. If not for the Dialog Remove statement. 20 Width 245 Height Calling listbox_handler 64 If the user clicks or double-clicks on the ListBox control. Dialog Remove Call go_to_view(i) ' act on user's choice. The NVIEWS program displays a dialog box with a ListBox control. The following Control ListBox clause adds a list to the Named Views dialog box.. ' see which list item the user clicked on. since user clicked on the name of a view.. the user can click on a list item and then choose OK. CommandInfo( ) function 154 © 2006 MapInfo Corporation.” The procedure calls the CommandInfo( ) function to determine whether the user clicked or double-clicked. Sub listbox_handler Dim i As SmallInt ' First. If the user double-clicked. or the user can double-click an item in the list. Dialog statement. See Also Alter Control statement.Control ListBox / MultiListBox clause The NVIEWS.or double-click.

or font style. Brush. BrushPicker. w specifies the control's width. MapBasic calls the handler procedure. brush (fill). in dialog box units. a dialog box appears to allow the user to change the style. Symbol. in dialog box units.Control PenPicker/BrushPicker/SymbolPicker/FontPicker clause Control PenPicker/BrushPicker/SymbolPicker/FontPicker clause Purpose Part of a Dialog statement. default width is 20. or Font expression. symbol (point). handler is the name of a handler procedure. style_expr is a Pen. must be a Pen expression if the control is a PenPicker). If the user clicks on the button. SymbolPicker. symbol. in dialog box units. The Hide keyword makes the control hidden initially. default height is 20. or font (text) style. adds a button showing a pen (line). The Disable keyword makes the control disabled (grayed out) initially. Brush. specifying what style will appear initially in the control. or FontPicker) is a button showing a pen. All rights reserved. Symbol. Dialog statement. ReadControlValue( ) function Reference Guide © 2006 MapInfo Corporation. if the user clicks on the Picker control. style_var is the name of a Pen. cannot be the same as the ID of another control in the dialog box. y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Calling handler ] [ Value style_expr ] [ Into style_var ] [ Disable ] [ Hide ] x. must be a Pen variable if the control is a PenPicker control). 155 . y specifies the control's position. Example Control SymbolPicker Position 140. control_ID is an integer.42 Into sym_storemarker See Also Alter Control statement. Syntax Control { PenPicker | BrushPicker | SymbolPicker | FontPicker } [ Position x. this expression type must match the type of control (for example. this variable type must match the type of control (for example. Description A Picker control (PenPicker. brush. or Font variable. and then clicks OK on the style dialog box which appears. h specifies the control's height.

each item appears as one item in the menu.Region. A pop-up menu is a list of items. The following sample Title clause demonstrates this syntax: Title "Town. if the first item selected. MapBasic 8. only the selected item appears on the dialog box. w specifies the control's width. All rights reserved.5 . if the clause is omitted. the dialog box includes a pop-up menu. str_array_var is the name of an array of string variables. Description If a Dialog statement includes a Control PopupMenu clause. control_ID is an integer.). If the user clicks on the control. default width is 80. The Disable keyword makes the control disabled (grayed out) initially.Control PopupMenu clause Control PopupMenu clause Purpose Part of a Dialog statement. Initially.County.Territory. one of which is selected at one time. 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. cannot be the same as the ID of another control in the dialog box. the entire menu appears. str_expr is a string expression. i_variable is the name of a SmallInt variable which stores the user's final selection (one. y specifies the control's position in dialog box units. The Title clause specifies the list of items that appear in the menu. in dialog box units. y ] [ Width w ] [ ID control_ID ] [ Calling handler ] [ Title { str_expr | From Variable str_array_var } ] [ Value i_selected ] [ Into i_variable ] [ Disable ] x. Syntax Control PopupMenu [ Position x. the first item appears selected.Entire state" 156 © 2006 MapInfo Corporation. handler is the name of a procedure to call when the user chooses an item from the menu. If the Title clause specifies a string expression containing a semicolon-delimited list of items. and the user can choose a different item from the menu. etc. containing a semicolon-delimited list of items to appear in the control. adds a popup menu control to the dialog box.

The following sample Title clause demonstrates this syntax: Title From Variable s_optionlist Example Control PopupMenu Title "Town. Reference Guide © 2006 MapInfo Corporation. control_ID is an integer. if the clause is omitted. 157 . y specifies the control's position in dialog box units. i_variable is the name of a SmallInt variable which stores the user's final selection (one. str_array_var is the name of an array of string variables.). str_expr is a string expression.Territory. 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. 150 See Also Alter Control statement. cannot be the same as the ID of another control in the dialog box. ReadControlValue( ) function Control RadioGroup clause Purpose Part of a Dialog statement. The Disable keyword makes the control disabled (grayed out) initially. the Title clause can specify an array of string variables. the first item appears selected. handler is the name of a procedure to call if the user clicks or double-clicks on any of the radio buttons.Control RadioGroup clause Alternately. if the first item selected. Syntax Control RadioGroup [ Position x. containing a semicolon-delimited list of items to appear in the control. Dialog statement. in which case each entry in the array appears as one item in the popup menu. All rights reserved. y ] [ ID control_ID ] [ Calling handler ] [ Title { str_expr | From Variable str_array_var } ] [ Value i_selected ] [ Into i_variable ] [ Disable ] [ Hide ] x.Region. adds a list of radio buttons to the dialog box.County.Entire state" Value 2 ID 5 Into i_map_scope Position 10. etc.

MapBasic 8.&Partial Details" Value 2 ID 2 Into i_details Calling rg_handler Position 15. The following sample Title clause demonstrates this syntax: Title "&Full Details. If the Title clause specifies a string expression containing a semicolon-delimited list of items. The currentlyselected item is indicated by a filled circle. in dialog box units. each item appears as one item in the list. y ] [ Width w ] [ Height h ] [ ID control_ID ] [ Title title_string ] [ Hide ] x. Each radio button is a label to the right of a hollow or filled circle. Dialog statement. The Title clause specifies the list of labels that appear in the dialog box. 42 See Also Alter Control statement. ReadControlValue( ) function Control StaticText clause Purpose Part of a Dialog statement. the dialog box includes a group of radio buttons. Only one of the radio buttons may be selected at one time. 158 © 2006 MapInfo Corporation.Control StaticText clause The Hide keyword makes the control hidden initially. The following sample Title clause demonstrates this syntax: Title From Variable s_optionlist Example Control RadioGroup Title "&Full Details.&Partial Details" Alternately. y specifies the control's position. adds a label to a dialog box.5 . Syntax Control StaticText [ Position x. Description If a Dialog statement includes a Control RadioGroup clause. in which case each entry in the array appears as one item in the list. All rights reserved. the Title clause can specify an array of string variables.

Description If you want the text string to wrap down onto multiple lines. If you omit the Width and Height clauses. 10 See Also Alter Control statement. cannot be the same as the ID of another control in the dialog box. the function ConvertToPline( ) does not alter the original object. ConvertToPline( ) returns a polyline that has the same shape and same number of nodes as the region. Thus. control_ID is an integer. However. include the optional Width and Height clauses. title_string is a text string to appear in the dialog box as a label. All rights reserved. Return Value A polyline object Description The ConvertToPline( ) function returns a polyline object which approximates the object parameter. The results obtained by calling ConvertToPline( ) are similar to the results obtained by choosing MapInfo Professional's Objects > Convert To Polyline command. Dialog statement ConvertToPline( ) function Purpose Returns a polyline object that approximates the shape of another object.ConvertToPline( ) function w specifies the control's width. in dialog box units. Example Control StaticText Title "Enter map title:" Position 5. the static text control shows only one line of text. may not be a point object or a text object. if the object parameter represents a region object. Syntax ConvertToPline( object ) object is the object to convert. See Also Objects Enclose statement Reference Guide © 2006 MapInfo Corporation. h specifies the control's height. The Hide keyword makes the control hidden initially. in dialog box units. 159 .

The convex hull polygon can be thought of as an operator that places a rubber band around all of the points. Otherwise. Other attributes are determined by the current pens or brushes. The polygon will be convex—no interior angle can be greater than 180 degrees. However. if the object parameter represents a rectangle. MapBasic 8. the ConvertToRegion( ) function does not alter the original object.5 . All rights reserved. Return Value A region object Description Retains most style attributes. 160 © 2006 MapInfo Corporation. MapInfo Professional adds a last node whose vertices are the same as the first node. or text object. ConvertToRegion( ) returns a region that looks like a rectangle. line. Thus. Syntax ConvexHull( inputobject ) inputobject is an object expression. Return Value Returns a region object. It will consist of the minimal set of points such that all other points lie on or inside the polygon. The results obtained by calling ConvertToRegion( ) are similar to the results obtained by choosing MapInfo Professional's Objects > Convert To Region command. Syntax ConvertToRegion( object ) object is the object to convert. A polyline whose first and last nodes are identical will not have the last node duplicated. may not be a point. The ConvertToRegion( ) function returns a region object which approximates the object parameter.ConvertToRegion( ) function ConvertToRegion( ) function Purpose Returns a region object that approximates the shape of another 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.

C. azimuth ] [ . 161 . miny ) ( maxx. false_northing ] [ . Dim Resulting_object as object select * from States where State_Name = "New York" Resulting_object = ConvexHull(selection. E. E. B. standard_parallel_2 ] ] [ . origin_longitude ] [ . Example The following program selects New York from the States file.obj) Insert Into States(obj) Values (Resulting_object) See Also: Create Object statement CoordSys clause Purpose Specifies a coordinate system. use the Create Object As ConvexHull statement. scale_factor ] [ . D. To create a convex hull around a set of objects. D.CoordSys clause Description The ConvexHull( ) function returns a region representing the convex hull of the set of points comprising the input object. F ] [ Bounds ( minx. maxy ) ] Syntax 2 CoordSys Nonearth [ Affine Units unitname. B. F ] Units unitname [ Bounds ( minx. unitname [ . miny ) ( maxx. false_easting ] [ . C. A. maxy ) ] Syntax 3 CoordSys Layout Units paperunitname Syntax 4 CoordSys Table tablename Reference Guide © 2006 MapInfo Corporation. standard_parallel_1 [ . Syntax 1 CoordSys Earth [ Projection type. The ConvexHull( ) function operates on one single object at a time. then creates a ConvexHull surrounding the selection. range ] ] [ Affine Units unitname. origin_latitude ] [ . All rights reserved. datum. A.

dictating how much of the Earth will be seen. B performs rotation or skewing along the X axis. in degrees. not a complete MapBasic statement. maxy is a float specifying the maximum y value.5 .CoordSys clause Syntax 5 CoordSys Window window_id type is a positive integer value representing which coordinate system to use. maxx is a float specifying the maximum x value. E performs rotation or skewing along the Y axis. window_id is an integer window identifier corresponding to a Map or Layout window. datum is a positive integer value identifying which datum to reference. All rights reserved. A performs scaling or stretching along the X axis. Note that CoordSys is a clause. Various statements may include the CoordSys clause. for a list of unit names. range is a float value from 1 to 180. Description The CoordSys clause specifies a coordinate system. for a list of unit names. minx is a float specifying the minimum x value. C performs shifting along the X axis. standard_parallel_1 and standard_parallel_2 are float latitude values. 162 © 2006 MapInfo Corporation. azimuth is a float angle measurement. D performs scaling or stretching along the Y axis. unitname is a string representing a distance unit of measure (for example. a Set Map statement can include a CoordSys clause. paperunitname is a string representing a paper unit of measure (for example. specifies a map projection to use in conjunction with the coordinate system. for example. origin_latitude is a float latitude value. in which case the Set Map statement will reset the map projection used by the corresponding Map window. in degrees. see Set Distance Units statement on page 570. scale_factor is a float scale factor. “in” for inches). MapBasic 8. “m” for meters). origin_longitude is a float longitude value. F performs shifting along the Y axis. optionally. tablename is the name of an open table. and. miny is a float specifying the minimum y value. in degrees. in degrees. see Set Paper Units statement on page 601.

false_easting. A MapBasic program must issue a Set CoordSys Layout statement before querying. The unitname parameter is the name of a paper unit. the Affine clause requires you to specify the derived coordinate units. 163 . while the formula for a Transverse Mercator projection uses the datum. The following Set CoordSys statement assigns a Layout window's coordinate system. If the Projection clause is omitted. If a MAP file is created using an affine transformation. When a CoordSys clause appears as part of a Set Map statement or Set Digitizer statement. and the Affine clause specifies the derived coordinate units. should be used in conjunction with the coordinate system.2 do not recognize the affine transformation constants in the CoordSys clause. creating or otherwise manipulating Layout objects. The Affine clause describes the affine transformation for producing the derived coordinate system. For example. older versions of MapInfo Professional will use the base coordinate system instead of the derived coordinate system. The Bounds clause defines the map's limits. and origin_latitude parameters. but only for non-Earth maps. MapBasic uses datum 0. objects may not be created outside of those limits. If the Projection clause is omitted. using inches as the unit of measure: Set CoordSys Layout Units "in" Use syntax 4 (CoordSys Table) to refer to the coordinate system in which a table has been saved. All rights reserved. The Bounds subclause is required for non-Earth maps when the CoordSys clause appears in any other statement. Mapinfow. see the MapInfo Professional documentation.1. if any. you may omit the Bounds clause. scale_factor. Reference Guide © 2006 MapInfo Corporation. unitname. the base coordinate system is Longitude/Latitude.CoordSys clause Use 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).prj. the Bounds subclause is ignored. you can increase the precision of the coordinates in the map by specifying narrower Bounds. origin_longitude. Use syntax 3 (CoordSys Layout) to define a coordinate system which represents a MapInfo Professional Layout window. such as the coordinate system used in a floor plan or other CAD drawing. Since the derived coordinates may be in different units than the base coordinates. unitname. Use syntax 5 (CoordSys Window) to refer to the coordinate system already in use in a window. and false_northing parameters. For more information on projections and coordinate systems. origin_latitude. the formula for a Robinson projection uses the datum. in which case MapInfo Professional uses default bounds that encompass the entire Earth. When specifying an Earth coordinate system. the base coordinate system is an arbitrary Cartesian grid. The Units clause specifies the base coordinate units. In the CoordSys Non-Earth case. or any MAP file. Every map projection is defined as an equation. Versions of MapInfo Professional prior to MapInfo Professional 4. Use syntax 2 to explicitly define a non-Earth coordinate system. such as “in” for inches or “cm” for centimeters. The optional Projection parameters dictate what map projection. and since the different projection equations have different sets of parameters. Note: In a Create Map statement. different CoordSys clauses may have varying numbers of parameters in the optional Projection clause.

0 Affine Units "ft". and the final zero specifies that the origin of the map should be at zero degrees longitude.19x + 2. y) represents the UTM Zone 10 base coordinates. Set Map CoordSys Earth The following example opens the table World. the second 12 specifies the Sphere datum.19. If a MapBasic application issues a Set CoordSys statement. 0. The Set Map statement below tells MapInfo Professional to display the Map window using the Robinson projection: Set Map CoordSys Earth Projection 12. The following example sets one Map window's projection to match the projection of another Map window.5. MapBasic 8. 12. "m". 12.57x . If the DCS coordinates are measured in feet. The new RWorld table will be saved with the Robinson projection.5 y1 = 0. and (x. 500000. This example assumes that two integer variables (first_map_id and second_map_id) already contain the window IDs of the two Map windows. The first 12 specifies the Robinson projection. x1 = 1.TAB" CoordSys Earth Projection 12. 0. Set Map Window second_map_winid CoordSys Window first_map_winid The following example defines a coordinate system called DCS that is derived from UTM Zone 10 coordinate system using the affine transformation.57.0 See Also Commit Table statement.81.81y . The following statement tells MapInfo Professional to display the Map window without any projection.0. "m". "m". Set CoordSys statement.21. -123. Open Table "world" As World Commit Table world As "RWORLD. Set Map statement 164 © 2006 MapInfo Corporation. All rights reserved. 0.20318. -20318. 1. Examples The Set Map statement controls the settings of an existing Map window. other MapBasic applications which are also in use will not be affected. -0.0 In this transformation. (x1. 74.21y + 84120. 2.5 . 0. then uses a Commit Table statement to save a copy of World under the name RWorld. the “m” specifies that the coordinate system should use meters. the CoordSys clause for DCS would be as follows: CoordSys Earth Projection 8. 84120.CoordSys clause Each MapBasic application has its own CoordSys setting that specifies the coordinate system used by the application.9996. 0. y1) represents the DCS derived coordinates.

The result returned from Cos( ) will be between one and negative one. To convert a radian value into degrees.5 See Also Acos( ) function. multiply that value by DEG_2_RAD. Return Value Float Description The Cos( ) function returns the cosine of the numeric num_expr value. multiply that value by RAD_2_DEG.DEF" Dim x. (Note that your program will need to Include “MAPBASIC. Asin( ) function. Sin( ) function. Tan( ) function Reference Guide © 2006 MapInfo Corporation. Syntax Cos( num_expr ) num_expr is a numeric expression representing an angle in radians. Atn( ) function. y As Float x = 60 * DEG_2_RAD y = Cos(x) ' y will now be equal to 0. To convert a degree value to radians. Example Include "MAPBASIC.Cos( ) function Cos( ) function Purpose Returns the cosine of a number.DEF” in order to reference DEG_2_RAD or RAD_2_DEG). 165 .5 ' since the cosine of 60 degrees is 0. which represents an angle in radians. All rights reserved.

Objects created on a Layout window. the object will be stored in the specified object variable. MapBasic 8. If the Into clause is not provided. All rights reserved. MapBasic uses inches as the default paper unit.Create Arc statement Create Arc statement Purpose Creates an arc object. end_angle specifies the arc's ending angle. MapBasic will attempt to store the object in the topmost window. var_name is the name of an existing object variable. Description The Create Arc statement creates an arc object. To use a different paper unit. however. while each y-coordinate represents the distance from the top edge of the page. y1 ) ( x2. y2 specifies the opposite corner of the ellipse's MBR. If no Pen clause is specified. ] window_id is a window identifier. the object will be stored in the appropriate place in the window (for example. in degrees. MapBasic uses a Longitude/Latitude coordinate system. x1. If the Into clause specifies a window identifier. if objects may not be stored in the topmost window (for example. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. Before creating objects on a Layout window.5 . the arc produced will be a section of this ellipse.. If the statement includes the optional Into Variable clause.. y2 ) start_angle end_angle [ Pen. By default. The Pen clause specifies a line style. in the editable layer of a Map window). Syntax Create Arc [ Into { Window window_id | Variable var_name } ] ( x1. use the Set Paper Units statement. if the topmost window is a grapher) no object will be created. see Pen clause on page 446 for more details. y1 specifies one corner of the minimum bounding rectangle (MBR) of an ellipse. the Create Arc statement uses the current MapInfo Professional line style (the style which appears in the Options > Line Style dialog box). start_angle specifies the arc's starting angle. The optional Pen clause specifies a line style. are specified in paper units: each x-coordinate represents a distance from the left edge of the page. By default. you must issue a Set CoordSys Layout statement. 166 © 2006 MapInfo Corporation. The x and y parameters use whatever coordinate system MapBasic is currently using. in degrees. x2. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window.

. Pen clause. in terms of the number of buttons across. 0 places the pad at the left edge of the top row of toolbars. 1 represents the second pad on the top row). 0. specified in paper units (for example. Syntax Create ButtonPad { title_string | ID pad_num } As button_definition [ button_definition .. Each button_definition clause can consist of the keyword Separator. x. “in” for inches. All rights reserved. and 0. y specify the pad's position when it is floating. y ) [ Units unit_name ] ] [ ToolbarPosition ( row. column specify the pad's position when it is docked as a toolbar (for example. column ) ] [ { Show | Hide } ] [ { Fixed | Float } ] title_string is the ButtonPad title (for example. 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 ODBC w is the pad width. “Drawing”). ] [ Title title_string ] [ Width w ] [ Position ( x. or it can have the following syntax: { PushButton | ToggleButton | ToolButton } Calling { procedure | menu_code | OLE methodname | DDE server. Update statement Create ButtonPad statement Purpose Creates a ButtonPad (toolbar). unit_name is a string representing paper units name (for example.Create ButtonPad statement See Also Insert statement. 167 . row. inches). “cm” for centimeters). topic } [ ID button_id ] [ Icon n [ File file_spec ] ] [ Cursor n [ File file_spec ] ] [ DrawMode dm_code ] [ HelpMsg msg ] [ ModifierKeys { On | Off } ] [ Enable ] [ Disable ] [ Check ] [ Uncheck ] Reference Guide © 2006 MapInfo Corporation.

DEF (for example. The first part of the msg string is the status bar help message. include the keyword Float. optionally. ID button_id specifies a unique button number. Each toolbar can be hidden. or only click with the tool. ToolTip help. This number can be used as a parameter to allow a handler to determine which button is in use (in situations where different buttons call the same handler) or as a parameter to be used with the Alter Button statement. For more information on ButtonPads. n can be one of the standard MapInfo icon codes listed in ICONS. menu_code is a standard MapInfo Professional menu code from MENU. MI_ICON_RULER). If the File sub-clause specifies the name of a file containing icon resources. Default is Off. include the keyword Fixed.DEF. its position is controlled by the Position clause. 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 keys affect “rubber-band” drawing if the user drags the mouse while using a ToolButton.Create ButtonPad statement procedure is the handler procedure to call when a button is used. MI_CURSOR_ARROW) from ICONS.DEF (for example. Once you have created a custom ButtonPad. n is an integer resource ID identifying a resource in the file. Description Use the Create ButtonPad statement to create a custom ButtonPad. see Alter ButtonPad statement on page 75. n is an integer resource ID identifying a resource in the file. If the File sub-clause specifies the name of a file containing icon resources. Cursor n specifies the shape the mouse cursor should adopt whenever the user chooses a ToolButton tool. meaning that the shift and control keys have no effect. server. For additional information about the capabilities of ToolButtons.5 . This clause applies only to ToolButtons. To create a fixed toolbar. A floating toolbar resembles a window. topic are strings specifying a DDE server and topic name. MapInfo Professional runs the menu command when the user uses the button. include the Hide keyword. To create a toolbar in the hidden state. DrawMode dm_code specifies whether the user can click and drag. n is a cursor code (for example. When a toolbar is floating. All rights reserved. its position is controlled by the ToolbarPosition clause. Each toolbar can be floating or fixed to the top of the screen (“docked”). such as the Info tool window. MapBasic 8.DEF. DM_CUSTOM_LINE) from ICONS. methodname is a string specifying an OLE method name. when it is docked. 168 © 2006 MapInfo Corporation. dm_ code is a code (for example. you can modify it using Alter Button statement and Alter ButtonPad statement. see the MapBasic User Guide. To create a floating toolbar. Icon n specifies the icon to appear on the button. The DrawMode clause applies only to ToolButtons. HelpMsg msg specifies the button's status bar help and. M_FILE_ OPEN).

For complete details on the string syntax. Connects through DDE to “server|topic” and sending an Execute message to the DDE server. 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).DEF. the event calls the procedure. 169 . The procedure must be part of the same MapBasic program. Makes a method call to the OLE Automation object set by MapInfo Professional's SetCallback method. All rights reserved. the event runs a standard MapInfo Professional menu command (the File > New command. in this example). See the MapBasic User Guide. Calling clause example Calling M_FILE_NEW Description If Calling is followed by a numeric code from MENU. If you specify a procedure name. The following table describes the available syntax.Create ButtonPad statement Calling Clause Options The Calling clause specifies what should happen when the user acts on the custom button. Calling my_procedure Calling OLE "methodname" Calling DDE "server". see the MapBasic User Guide. Example Create ButtonPad "Utils" As PushButton HelpMsg "Choose this button to display query dialog" Calling button_sub_proc Icon MI_ICON_ZOOM_QUESTION ToolButton HelpMsg "Use this tool to draw a new route" Calling tool_sub_proc Icon MI_ICON_CROSSHAIR DrawMode DM_CUSTOM_LINE ToggleButton HelpMsg "Turn proximity checking on/off" Calling toggle_prox_check Icon MI_ICON_RULER Check Title "Utilities" Width 3 Show Reference Guide © 2006 MapInfo Corporation."topic" In the last two cases.

. ] } ] [ Default Frame Style { def_frame_style } [ Font. even buttons defined by other MapBasic applications. See Also Alter Button statement. MapBasic 8. Alter ButtonPad statement Create ButtonPads As Default statement Purpose Restores standard ButtonPads (for example.. Syntax Create ButtonPads As Default Description This statement destroys any custom ButtonPads and returns MapInfo Professional's standard ButtonPads (Main. and Tools) to their default states.. the Main ButtonPad) to their default state. Alter ButtonPad statement. y ) [ Units paper_units ] ] [ Width win_width [ Units paper_units ] ] [ Height win_height [ Units paper_units ] ] [ Window Title { legend_window_title } [ ScrollBars { On | Off } ] [ Portrait | Landscape | Custom ] [ Style Size { Small | Large } [ Default Frame Title { def_frame_title } [ Font. Use this statement with caution. Create ButtonPad statement Create Cartographic Legend statement Purpose Creates and displays cartographic style legends as well as theme legends for an active map window...Create ButtonPads As Default statement See Also Alter Button statement.5 . The Create ButtonPads As Default statement destroys all custom buttons. Drawing. All rights reserved. ] } ] [ Default Frame Subtitle { def_frame_subtitle } [ Font.. ] } ] [ Default Frame Border Pen [ [ pen_expr ] Frame From Layer { map_layer_id | map_layer_name [ Using [ Column { column | Object } [ FromMapCatalog { On | Off }]] 170 © 2006 MapInfo Corporation. Syntax Create Cartographic Legend [ From Window map_window_id ] [ Behind ] [ Position ( x.

. It can include the special character “#” which will be replaced by the current layer name. ] } SubTitle { frame_subtitle [ Font. Brush . “cm” for centimeters).. or region in a custom frame. paper_units is a string representing a paper unit name (for example. then it is used instead of the default. win_width is the desired width of the window. column is an attribute column name from the frame layer's table. y ) [ Units paper_units ] ] Title { frame_title [ Font. win_height is the desired height of the window. If a border pen clause exists at the frame level. MakePen( width. x states the desired distance from the top of the workspace to the top edge of the window. line.| Symbol Symbol. 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. color ). then it will be used instead of the def_frame_title. For a theme layer you must specify the map_layer_id. “Region”. def_frame_style is a string that displays next to each symbol in each frame.. “% of #” will expand to “Region of States” for the states. ] [ Region Pen... ] } ] Border Pen pen_expr ] Style [ Font... pen_expr is a Pen expression. 171 . “Point.. For example. def_frame_subtitle is a string which defines a default frame subtitle. can be a SmallInt (for example... ] [ [ [ [ [ map_window_id is an integer window identifier which you can obtain by calling the FrontWindow( ) function and WindowID( ) function.. If a Subtitle clause is defined here for a frame.. The % character will be replaced by the text “Line”.. frame_subtitle is a string which defines a frame subtitle..] [ Norefresh ] [ Text { style_name } { Line Pen. If a Title clause is defined here for a frame.. 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 example. ] [ Line Pen.... } | Collection [ Symbol . pattern. style_name is a string which displays next to a symbol. All rights reserved. If a default border pen is defined. It can include the special character “#” which will be replaced by the current layer name.. frame_title is a string which defines a frame title.] } ] [ .. Reference Guide © 2006 MapInfo Corporation. def_frame_title is a string which defines a default frame title.. . The “#” character will be replaced with the layer name.. as appropriate for the symbol. | Region Pen..Create Cartographic Legend statement [ Label { expression | Default } ] Position ( x. then it will be become the default for the frame. Brush. map_layer_id or map_layer_name identifies a map layer. y states the desired distance from the left of the workspace to the left edge of the window.. then it will be used instead of the def_frame_subtitle.tab layer.

Title. If no font is specified at any level. subtitle and style name. A Create Cartographic Legend statement can override the current paper units by including the optional Units subclause within the Position. symbols. The upper left corner of MapInfo Professional's workspace has the position 0. If Custom is specified. then it will become the default for the frame. Each cartographic and thematic styles legend will be connected to one. The optional Width and Height clauses control the window's size. or style name font is defined. The Position clause at the frame level specifies the position of a frame if Custom is specified. MapBasic 8. Window position and size values use paper units settings. All clauses pertaining to the entire legend (scrollbars. Subtitle. They are not used for thematic layers. and sizes represented by the theme. Cartographic frames display a map layer's styles. 0. For a thematic layer. then the frame level font is used. Portrait or Landscape describes the orientation of the legend frames in the window. which defaults to inches. small-sized legend samples are used in Legend windows. The optional Behind clause places the legend behind the Thematic Map window. then the current text style is used and the point sizes are 10. this information is gotten automatically from the theme. At least one Frame clause is required. The Position. 9. etc.) must proceed the first Frame clause. If you specify Style Size Small.5 . The optional Position clause controls the window's position on MapInfo Professional's workspace. a MapBasic program can change this setting through the Set Paper Units statement.Create Cartographic Legend statement 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. legend frames display the colors. If you specify Style Size Large. or Style clause exists and includes a Font clause. 172 © 2006 MapInfo Corporation. The From Layer clause must be the first clause after the Frame clause. SubTitle. and Style clauses at the frame level are used only for map layers. such as “in” (inches) or “cm” (centimeters). Portrait results in an orientation that is down and across. You can create a frame for each cartographic or thematic map layer you want to include on the legend. All rights reserved. Border Pen. The optional Style Size clause controls the size of the samples that appear in legend windows. The cartographic and thematic frames will include a legend title and subtitle. subtitle. You can create frames that have styles based on the Map window's style or you can create your own custom frames. Landscape results in an orientation that is across and down. If a default frame title. and only one. and 8 for title. MapBasic has a current paper units setting. and/or Height clauses. Use the ScrollBars clause to show or hide scroll-bars on a Map window. The Font clause specifies a text style. larger-sized legend samples are used. Width. you can specify a custom Position clause for a frame. Map window so that there can be more than one Legend window open at a time. width. If a frame level Title.

Instead. Example The following example shows how to create a frame for a Map window's cartographic legend. FromMapCatalog OFF retrieves the unique map styles for the live table from the server. or Default (meaning that the default frame style pattern is used when creating each style's text. If the table is not a live access table. you must use the Title clause instead of the From Window clause. then Regions. If a Label is defined. If legend metadata keys exist and you want to override them. ' To obtain an ID. Region. All rights reserved. or Symbol clause.Create Cartographic Legend statement The Style clause and the NoRefresh keyword allow you to create custom frames that are not overwritten when the legend is refreshed. each frame layer's TAB file is searched for metadata values for the title. ' and store the Layout window's ID in i_layout_id. If Column is defined. 173 . Collection objects are treated separately. Dim i_layout_id. MapBasic reverts to the default behavior for a non-live access table instead of throwing an error. the default is the default frame style pattern. FromMapCatalog ON retrieves styles from the MapCatalog for a live access table.e. i_map_id As Integer Dim s_title As String ' here. line. Collection objects are drawn last.2) (4. map styles). If no metadata value exists for Label. The default behavior for a non-access table is FromMapCatalog Off (i. This table must be a live access table that supports per record styles for this to occur. Multipoint objects are treated as Point objects. it draws Point symbols first. If the NoRefresh keyword is used in the Style clause. or Object denotes the object column (meaning that legend styles are based on the unique styles in the map file). you would store the Map window's ID in i_map_id. When MapInfo Professional creates a Legend based on object types. the default is Object. Initially. then the table is not scanned for styles. This is done with the Text clause and appropriate Line. subtitle. s_title = "Legend of " + WindowInfo(i_map_id. The default is Default. call FrontWindow( ) or WindowID( ). specify expression as a valid expression. which is to get the default styles from the MapCatalog (FromMapCatalog ON). 5) Title s_title Reference Guide © 2006 MapInfo Corporation. then Lines. Legend windows are a special case: To create a frame for a Legend window. The default is Object. Inside collection objects the order of drawing is point. WIN_INFO_NAME) Set CoordSys Layout Units "in" Create Frame Into Window i_layout_id (1.. unless the style clause contains text). If no metadata value exists for the column. you must use the corresponding MapBasic syntax. and then region samples. column and label. column is the name of an attribute column in the frame layer's table. the Style clause must contain your custom list of definitions for the styles displayed in the frame. If the live table does not support per record styles than the behavior is to revert to the default behavior for live tables.

indicating the circle radius. By default. which has optional Pen and Brush clauses. MapBasic 8. WindowInfo( ) function CreateCircle( ) function Purpose Returns an Object value representing a circle. Alter Cartographic Frame statement. indicating the y-position (for example. Remove Cartographic Frame statement. you can issue a Set Style statement before calling CreateCircle( ). instead of calling CreateCircle( ). change the title to the following. WW_INFO_NAME) See Also Set Cartographic Legend statement. radius is a float value. 174 © 2006 MapInfo Corporation. y is a float value. MapBasic uses miles as the distance unit. Longitude) of the circle's center. By default. y. Latitude) of the circle's center. Return Value Object Description The CreateCircle( ) function returns an Object value representing a circle. MapBasic uses a Longitude/Latitude coordinate system. although the Set Distance Units statement can re-configure MapBasic to use a different distance unit. in whatever distance unit MapBasic is currently using. Note: MapBasic's coordinate system is independent of the coordinate system of any Map window. you can issue a Create Ellipse statement.CreateCircle( ) function This creates a frame for a Cartographic Legend window. Create Legend statement. To create a circle object with a specific Brush.5 . radius ) x is a float value. Syntax CreateCircle( x. Alternately. Set Window statement. Add Cartographic Frame statement. The circle uses whatever Brush style is currently selected. indicating the x-position (for example. To create a frame for a Thematic Legend window. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. S_title="Theme Legend of " + WindowInfo (I_map_id. The x and y parameters use whatever coordinate system MapBasic is currently using. The radius parameter specifies the circle radius. All rights reserved.

Note: Before creating objects on a Layout window. The Update statement uses the CreateCircle( ) function to build a circle object for each row in the table.Create Collection statement The circle object created through the CreateCircle( ) function could be assigned to an Object variable. Open Table "sites" Insert Into sites (obj) Values ( CreateCircle(-72. Update statement Create Collection statement Purpose Combines points. Error Conditions ERR_FCN_ARG_RANGE is generated if an argument is outside of the valid range. Insert statement. The CreateCircle( ) function is used within the body of the Insert statement to specify the graphic object that is attached to the new row. 42.4. Each row in the table describes a radio broadcast tower. and the Radius column indicates each tower's broadcast area. you must issue a Set CoordSys Layout statement. and the Radius column contains radius values. and closed objects into a single object. The collection object displays in the Browser as a single record. ycoord. Examples The following example uses the Insert statement to insert a new row into the table Sites. Each circle object will have a radius derived from the Radius column. linear objects. 175 . and Radius. All rights reserved. or inserted into a new row of a table (using an Insert statement). Open Table "towers" Update towers Set obj = CreateCircle(xcoord. each row in the Towers table will have a circle object attached. the Ycoord column contains latitude values. Following this Update statement. Syntax Create Collection [ num_parts ] [ Into { Window window_id | Variable var_name } ] Multipoint [ num_points ] Reference Guide © 2006 MapInfo Corporation. Ycoord.5. stored in an existing row of a table (through the Update statement). and each circle will be centered at the position indicated by the Xcoord and Ycoord columns. radius) See Also Create Ellipse statement. The Xcoord column contains longitude values. 20) ) The following example assumes that the table Towers has three columns: Xcoord.

y2 ) [ .1) region 1 3 (1.-2) (4.-3) (3.. num_sections specifies how many sections the multi-section polyline will contain.. ] [ Pen.2) (-2.-5) (5.4) pline 3 (-1.6) (6.3) (-3.-6) (6. ] .21) (22.2) (3. ] [ Symbol.-3) (3. num_polygons is the number of polygons inside the Collection object.5) 4 (-3.1) (2. y2 ) [ . center_y ) ] Pline [ Multiple num_sections ] num_points ( x1..-2) (-2..5) (-5.4) 4 (11. ] [ Pen...3) pline multiple 2 2 (-6.2) (4.1) (2..5 .22) (23.1) (3. y1 ) ( x2.2) (3..0) (1.24) pline 3 (-1...11) (12.3) insert into test (obj) values (a) create collection region 2 4 (-5. ] Region num_polygons [ num_points1 ( x1. ] [ Smooth..14) (19..6) 2 (-6.1) (3.1) (-1. ] [ Center ( center_x.-6) multipoint 6 (2. y1 ) ( x2. ] num_parts is the number of non-empty parts inside a collection.-4) See Also Create MultiPoint statement 176 © 2006 MapInfo Corporation. Example create collection multipoint 2 (0.. ] [ Brush. MapBasic 8.Create Collection statement ( x1.-2) (2.20) 3 (21.. y1 ) ( x2.0) (1..12) (13.. y1 ) ( x2. This number is from 0 to 3 and is optional for MapBasic code (it is mandatory for MIF files). ] ] [ num_points2 ( x1.-2) (4.. y2 ) [ . y2 ) [ ....-5) (5. All rights reserved.1) region 3 3 (1.3) dim a as object create collection into variable a multipoint 2 (0.

You will have to delete the cutter object manually from your editable layer. and a set of polylines as a selection object. 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 Target object could be a series of islands (for example. and the Polyline could be used to divide the islands into two sets without actually intersecting any of the islands. The polyline is then extended. The extended Polyline should divide the Target space into two portions. Example Open Table "C:\MapInfo_data\TUT_USA\USA\STATES. if necessary. One Region object will be created and returned which represents one of these two portions. All rights reserved. then this operation can be immediately followed by an Object Split operation. so that it covers the MBR. The Polyline selection must contain no breaks or self intersections. however. contiguous section. or using the Set Target statement. Given this revised set of Target objects. does not have to intersect the Target object itself. The original Polyline object(s) will remain. as well as a new set of Target objects which may be a subset of the original set of Target objects. For example. as well as this new Region cutter object. and an editable target must exist. The Polyline. If the MBR of a Target does not intersect the Polyline. The new Region object will now be the selected object. as appropriate Target objects are set. This is set by choosing Objects > Set Target. but will no longer be selected. 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 objects contained in the selection must represent a single. Hawaii). a cumulative MBR of all of these objects is calculated and represents the overall space to be split. one or more Polyline objects must be selected. 177 . Us_hiway select * from States where state = "NY" Set target On select * from Us_hiway where highway = "I 90" Reference Guide © 2006 MapInfo Corporation. You need to provide a set of Target objects.Create Cutter statement Create Cutter statement Purpose Produces a Region object that can be used as a cutter for an Object Split operation. This statement returns the revised set of Target objects (still set as the Target). Note: The cutter object still remains in the target layer. This Region object will be inserted into the Target table (which must be an editable table). Syntax Create Cutter Into Target Description Before using Create Cutter. then that Target will be removed from the Target list.TAB" Map from States. If the resulting Region object is suitable.TAB" Open Table "C:\MapInfo_data\TUT_USA\USA\US_HIWAY. and a suitable Region cutter object is selected.

If the statement includes the optional Into Variable clause. If the Into clause is not provided.. x1. are specified in paper units: each x-coordinate represents a distance from the left edge of the page. y1 ) ( x2. var_name is the name of an existing object variable. if objects may not be stored in the topmost window (for example. y2 ) [ Pen. The x and y parameters use whatever coordinate system MapBasic is currently using. If the Into clause specifies a window identifier. the object will be stored in the specified object variable.5 . All rights reserved. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window. MapBasic 8. By default. MapBasic attempts to store the object in the topmost window. otherwise. If the object's Minimum Bounding Rectangle (MBR) is defined in such a way that the x-radius equals the y-radius. Description The Create Ellipse statement creates an ellipse or circle object. in the editable layer of a Map window).. By 178 © 2006 MapInfo Corporation.. Syntax Create Ellipse [ Into { Window window_id | Variable var_name } ] ( x1. x2. ] [ Brush. the object will be a circle. while each y-coordinate represents the distance from the top edge of the page. y1 specifies one corner of the rectangle which the ellipse will fill.Create Ellipse statement Create Cutter Into Target Objects Split Into Target See Also Set Target statement Create Ellipse statement Purpose Creates an ellipse or circle object. the object will be stored in the appropriate place in the window (for example. however. The Pen clause specifies a line style. ] window_id is a window identifier. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. Objects created on a Layout window. y2 specifies the opposite corner of the rectangle. MapBasic uses a Lat6itiude/Longitude coordinate system.. the object will be an ellipse. The Brush clause specifies a fill style. if the topmost window is a grapher) no object will be created.

Pen clause. var_name is the name of an Object variable.. x2. Similarly. 179 . The Brush clause specifies a fill style. Reference Guide © 2006 MapInfo Corporation. CreateCircle( ) function. the new frame is added to the topmost Layout window. see Pen clause on page 446 for more details. Insert statement. y1 specifies one corner of the new frame to create. If no layout_ win_id is specified. y2 specifies the other corner. contents_win_id is an integer window ID indicating which window will appear in the frame. The Pen clause specifies a line style... see Brush clause on page 109 for more details. not needed if the From Window clause is used. you must issue a Set CoordSys Layout statement. ] [ Title title ] [ From Window contents_win_id ] [ FillFrame { On | Off } ] x1. title is a string identifying the frame contents (for example. Before creating objects on a Layout window. you must issue a Set CoordSys Layout statement. MapBasic uses inches as the default paper unit. the Create Ellipse statement uses the current MapInfo Professional line style (the style which appears in the Options > Line Style dialog box). See Also Brush clause. y2 ) [ Pen. All rights reserved. Description The Create Frame statement creates a new frame within an existing Layout window. Before creating objects on a Layout window. If no Pen clause is specified. To use a different paper unit. “WORLD Map”)..Create Frame statement default. ] [ Brush. Update statement Create Frame statement Purpose Creates a new frame in a Layout window. y1 ) ( x2. use the Set Paper Units statement. The optional Pen clause specifies a line style. Syntax Create Frame [ Into { Window layout_win_id | Variable var_name } ] ( x1. the optional Brush clause specifies a fill style. layout_win_id is a Layout window's integer window identifier.

the entire frame is filled with an image of the window. WIN_INFO_NAME) Set CoordSys Layout Units "in" Create Frame Into Window i_layout_id (1. If you specify both the Title clause and the From Window clause. For example. or Cartographic Legend window. Use the From Window clause to specify which window should appear inside the frame. If the title string does not refer to an existing window. or if title is an empty string (""). A window must already be open before you can create a frame containing the window. The Pen clause dictates what line style will be used to display the frame. the frame will be empty. which appears if you double-click a frame. Theme Legend windows are a special case. and examine the workspace file in a text editor. i_map_id As Integer Dim s_title As String ' here. you would store the Cartographic Legend window's ID 180 © 2006 MapInfo Corporation. ' To obtain an ID. the Title clause should read Title "WORLD Map". ' and store the Layout window's ID in i_layout_id. to identify a Map window which displays the table WORLD. If you specify FillFrame On. you should use the From Window clause since there may be more than one cartographic legend window per map. create a Layout. save the workspace. Example The following examples show how to create a frame for a Map window's thematic legend. To create a frame for a Theme Legend window. For example. specify From Window i_map (where i_ map is an integer variable containing the Map's window identifier).2) (4.5 . you must use the Title clause instead of the From Window clause. (This is analogous to checking the Fill Frame With Contents check box in MapInfo Professional's Frame Object dialog box. the aspect ratio of the window affects the appearance of the frame. and the Brush clause dictates the fill style used to fill the frame window. To see an example of the Create Frame statement. in other words. to make a Map window appear inside the frame. re-sizing a Map window to be tall and thin causes the frame to appear tall and thin. MapInfo Professional preserves Layout window settings by storing Create Frame statements in the workspace file. you would store the Map window's ID in i_map_id. MapBasic 8. the latter clause takes effect. 5) Title s_title To create a frame for a Map window's cartographic legend. call FrontWindow( ) or WindowID( ). s_title = "Theme Legend of " + WindowInfo(i_map_id.Create Frame statement Between sessions. Dim i_cartlgnd_id As Integer ' here. The Title clause provides an alternate syntax for specifying which window appears in the frame. All rights reserved. The FillFrame clause controls how the window fills the frame. Dim i_layout_id.) If you specify FillFrame Off (or if you omit the FillFrame clause entirely).

] tablename is the “alias” name of an open table from which to get data points. If not provided. this is usually zero. Pen clause.Create Grid statement ' in i_cartlgnd _id. filespec specifies the fully qualified path and name of the new grid file..MIG files are created.] [ Round rounding_factor ] {[ Cell Size cell_size [ Units distance_unit ]] | [ Cell Min n_cells ]} [ Border numcells ] Interpolate With interpolator_name Version version_string Using num_parameters parameter_name : parameter_value [ parameter_name : parameter_value . Reference Guide © 2006 MapInfo Corporation. Insert statement. value_to_ignore is a value to be ignored.2) (4. All rights reserved. such as a column name. ' To obtain an ID. No grid theme will be created for a row if the row's value matches the value to be ignored. 181 ... call FrontWindow( ) or WindowID( ). Coordsys is an optional CoordSys clause which is the coordinate system that the grid will be created in. which MapBasic displays as a raster table in a Map window. Set Layout statement. By default..MIG extension. Syntax Create Grid From tablename With expression [ Ignore value_to_ignore ] Into filespec [ Type grid_type ] [ Coordsys.. Update statement Create Grid statement Purpose Produces a raster grid file. expression is the expression by which the table will be shaded. 5) From Window i_cartlgnd_id See Also Brush clause. Set CoordSys statement. ] [ Clipping { Object obj } | { Table tablename } ] Inflect num_inflections By Percent at color : inflection_value [ color : inflection_value . the grid will be created in the same coordinate system as the source table. . Layout statement. Create Frame Into Window i_layout_id (1.. It will have a . grid_type is a string expression that specifies the type of grid file to create. Refer to CoordSys clause on page 161 for more information.

numcells defines the number of cells to be added around the edge of the original grid bounds. right. top. specifying the number of color:inflection_value pairs. Round is a numeric expression. specifying the name part of a parameter_name:parameter_ value pair. z) values from the table specified in the From clause. num_inflections is a numeric expression. you would specify “cell min 200". but it would be at least that wide and high. specifying the size of a grid cell in distance units. cell_size is a numeric expression. and passes those points and their data values to an interpolator. interpolator_name is a string expression. inflection_value is a numeric expression. The dimensions of the grid can be specified in two ways. 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. part of a color:value inflection pair. such as miles. One is by specifying the size of a grid cell in distance units. n_cells is a numeric expression that specifies the height or width of the grid in cells. specifying the rounding factor applied to the inflection values. specifying the name of the interpolator to use to create the grid. It gets the z values by evaluating the expression specified in the With clause with respect to the table. specifying the number of interpolator parameter name:value pairs. specifying the value part of a parameter_ name:parameter_value pair. specifying the units for the preceding cell size. num_parameters is a numeric expression. that cell value will not be written out and a null cell is written in its place. MapBasic 8. By Percent at specifies that the subsequent color:Inflection_value pairs represent a color value and percentage value. If not present. The other is by specifying a minimum height or width of the grid in terms of grid cells. specifying the version of the interpolator that the parameters are meant for. the actual grid dimensions would not be 200 by 200. color is a color expression of. The Create Grid statement reads (x. if you wanted the grid to be at least 200 cells wide by 200 cells high. parameter_value is a numeric expression. The interpolator produces a raster grid file. Depending on the aspect ratio of the area covered by the grid. the distance units from the table's coordinate system are used. y. If a grid cell is not within the object. Description A grid surface theme is a continuous raster grid produced by an interpolation of point data. parameter_name is a string expression. This is an optional parameter. The Create Grid statement takes a data column from a table of points. and bottom of the original grid dimensions. For example. 182 © 2006 MapInfo Corporation.5 . distance_unit is a string expression. specifying the value of a color:inflection_value pair. numcells will be added to the left. All rights reserved. which MapBasic displays as a raster table in a Map window. Only the portion of the grid theme within the object will display.Create Grid statement obj is an object to clip grid cells to. version_string is a string expression.

Reference Guide © 2006 MapInfo Corporation.tab" Interactive Map From States Open Table "C:\Us_elev.5 RGB(0. 0) : 7252 RGB(255. 0) : 10871.5 RGB(255.tab" Interactive Add Map Auto Layer Us_elev set map redraw off Set Map Layer 1 Display Off set map redraw on create grid from Us_elev with Elevation_FT into "C:\Us_elev_grid" clipping table States inflect 5 at RGB(0. 255) : 3632. 255) : 13 RGB(0. 0. 255. column is the name of a column in the open table. 183 . 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 Set Map statement Create Index statement Purpose Creates an index for a column in an open table. Syntax Create Index On table ( column ) table is the name of an open table. All rights reserved. 255.Create Index statement Example Open Table "C:\States. 255.

Refer to the Create Cartographic Legend statement on page 170 for more information.0 and later. the Create Cartographic Legend statement allows you to create and display cartographic style legends. such as a Visual Basic application.Create Legend statement Description The Create Index statement creates an index on the specified column. Example The following example creates an index for the “Capital” field of the World table. MapInfo Professional uses Indexes in operations such as Query > Find. MapBasic 8. 184 © 2006 MapInfo Corporation. use the Open Window Legend statement. Syntax Create Legend [ From Window window_ID ] [ { Show | Hide } ] window_ID is an integer. Use the Commit Table statement to save edits. even when the Map window is not active. otherwise. this statement is useful in “Integrated Mapping” applications. Drop Index statement. Thematic Legend window. where MapInfo Professional windows are integrated into another application. the new window is tied to the most recently used Map. in addition to the standard MapInfo Professional Legend window.5 . Note: MapInfo Professional cannot create an index if the table has unsaved edits. Open Table "world" Interactive Create Index on World(Capital) See Also Alter Table statement. see the MapBasic User Guide. Commit Table statement Create Legend statement Purpose Creates a new Theme Legend window tied to the specified Map window. (To open MapInfo Professional's standard Legend window. representing a MapInfo Professional window ID for a Map window. For information about Integrated Mapping. Also. the new Theme Legend window is tied to the window that you specify. If you include the From Window clause. Description This statement creates a special floating. Create Table statement. For MapInfo Professional versions 5.) The Create Legend statement is useful if you want the Legend of a Map window to always be visible. Indexes also improve the performance of queries in general. All rights reserved.

The x and y parameters use the current coordinate system. indicating the y-position of the line's ending point. ) of the line's starting point. with an optional Pen clause. indicating the x-position of the line's ending point. determine the new window's integer ID by calling WindowID( 0 ). All rights reserved. Use that window ID in subsequent statements (such as the Set Window statement). you could issue the Set Style statement before calling CreateLine( ) or you could issue a Create Line statement. 185 . MapBasic uses a Longitude/Latitude coordinate system. y1. By default. To create a line object with a specific Pen style. x2 is a float value. or inserted into a new row of a table (through an Insert statement). indicating the x-position (for example. you must first issue a Set CoordSys Layout statement. x2. indicating the y-position (for example. Set Window statement CreateLine( ) function Purpose Returns an Object value representing a line. You can then show the hidden window by using the Set Window…Show statement. y2 ) x1 is a float value. The line object created through the CreateLine( ) function could be assigned to an Object variable. The new Theme Legend window is created according to the parent and style settings that you specify through the Set Next Document statement. Use the Set CoordSys statement to choose a new system. the window is created in a hidden state. stored in an existing row of a table (through the Update statement). If you need to create objects on a Layout window. See Also Create Cartographic Legend statement. The line object will use whatever Pen style is currently selected. After you issue the Create Legend statement. Reference Guide © 2006 MapInfo Corporation.CreateLine( ) function If you include the optional Hide keyword. Syntax CreateLine( x1. Set Next Document statement. Return Value Object Description The CreateLine( ) function returns an Object value representing a line. y2 is a float value. y1 is a float value. Latitude) of the line's starting point. Open Window statement.

All rights reserved. y2 specifies the ending point of the line. Description The Create Line statement creates a line object. y1) ( x2. If the Into clause specifies a window identifier.. The Pen clause specifies a line style. The x and y parameters use whatever coordinate system MapBasic is currently using. Insert statement. If the statement includes the optional Into Variable clause. ] window_id is a window identifier.Create Line statement Example The following example uses the Insert statement to insert a new row into the table Routes. MapBasic will attempt to store the object in the topmost window.. Open Table "Routes" Insert Into routes (obj) Values (CreateLine(-72. y2) [ Pen. the object will be stored in the appropriate place in the window (for example. MapBasic 8. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system.435)) See Also Create Line statement. if objects may not be stored in the topmost window (for example.5 . -72. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window. Objects created on a Layout window.568. are specified in paper units: each x-coordinate represents a distance from the left 186 © 2006 MapInfo Corporation. If the Into clause is not provided. the object will be stored in the specified object variable.431. var_name is the name of an existing object variable. x2. if the topmost window is a grapher) no object will be created. The CreateLine( ) function is used within the body of the Insert statement. Syntax Create Line [ Into { Window window_id | Variable var_name } ] ( x1. 42. 42. MapBasic uses a Longitude/Latitude coordinate system. Update statement Create Line statement Purpose Creates a line object.55. in the editable layer of a Map window). x1. however. y1 specifies the starting point of a line. By default.

Create Map statement edge of the page. if you wish to temporarily change the projection in which a map is displayed. Description The Create Map statement makes an open table mappable. use the Set Paper Units statement. The optional Pen clause specifies a line style. This statement does not open a new Map window. See Also CreateLine( ) function. and you wish to permanently change the projection of the map. To use a different paper unit. Syntax Create Map For table [ CoordSys. By default. use the Map statement. Note: If you need to create objects on a Layout window. 187 . The Create Map statement does not work on linked tables. doing so will delete all map objects from the table. Alternately. To make a linked table mappable. use the Server Create Map statement. so that it can be displayed in a Map window. issue a Set Map statement with a CoordSys clause. while each y-coordinate represents the distance from the top edge of the page. To open a new Map window. you must first issue a Set CoordSys Layout statement. use a Commit Table As statement. Insert statement. Pen clause. making the table mappable.. the Create Line statement will use the current MapInfo Professional line style. MapBasic uses inches as the default paper unit. If a table already has a map attached.. from_table is the name of an open table from where to copy a coordinate system. Reference Guide © 2006 MapInfo Corporation. If no Pen clause is specified. You should not perform a Create Map statement on a table that is already mappable. Update statement Create Map statement Purpose Modifies the structure of a table. All rights reserved. ] Using from_table] table is the name of an open table. see Pen clause on page 446 for more details.

the table will use the current MapBasic coordinate system. Syntax Create Map3D [ From Window window_id | MapString mapper_creation_string ] [ Camera [ Pitch angle | Roll angle | Yaw angle | Elevation angle ] | [ Position ( x. Server Create Map statement. vu_3. a specific metropolitan area). or approximately 4 inches). All rights reserved. Create Table statement. In this case. coordinates are precise to one millionth of a degree. Map statement. See Also Commit Table statement. z ) | FocalPoint ( x. see CoordSys clause on page 161. which sets limits on the minimum and maximum coordinates that can be stored in the map. • Note that the CoordSys clause affects the precision of the map. Set Map statement Create Map3D statement Purpose Creates a 3DMap with the desired parameters. Camera specifies the camera position and orientation. 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. The CoordSys clause includes a Bounds clause. the coordinate system used will be identical to that used in the from_table. CoordSys clause. vu_2. z ) ] | [ Orientation ( vu_1. and must be mappable or an error will occur. clip_near. vpn_1. y. clip_far )]] [ Light [ Position ( x. MapBasic 8. For a complete listing of the CoordSys syntax. Drop Map statement. 188 © 2006 MapInfo Corporation.Create Map3D statement Specifying the Coordinate System Use one of the following two methods to specify a coordinate system: • Provide the name of an already open mappable table as the from_table portion of the Using clause. If you know in advance that the map you are creating is limited to a finite area (for example. z ) | Color lightcolor ] ] [ Resolution ( res_x. The from_table must be a currently open table. vpn_2. MapInfo Professional uses default bounds that encompass the entire Earth (in which case. you can increase the precision of the map's coordinates by specifying bounds that confine the map to that area. vpn_3.5 . Explicitly supply the coordinate system information through a CoordSys clause (set in preferences). 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. y. y. If you omit the Bounds clause.If you omit both the CoordSys clause and the Using clause.

A 3DMap keeps a Mapper creation string as its texture generator. vu_2. a value <1 will scale down the topological features in the z direction. Resolution is the number of samples to take in the x and y directions. each will be represented in the 3DMap window. clip_far) (used specifically for persistence of view). vu_3). This string will also be prevalent in the workspace when the 3DMap window is persisted. Position indicates the camera/light position. Do not specify this for unit-less grids (i. Elevation adjusts the current camera's rotation about the x axis centered at the camera's focal point. Pitch adjusts the camera's current rotation about the x axis centered at the camera's origin. These values can increase to a maximum of the grid resolution. Another example is: Reference Guide © 2006 MapInfo Corporation. y dimension. This option needs to be specified at creation time. ViewPlane Normal (vpn_1. You cannot change them later with the Set Map3D statement or the Properties dialog box. and Clipping Range (clip_near. Yaw adjusts the camera's current rotation about the y axis centered at the camera's origin. grids generated using temperature or density). The resolution values can increase to a maximum of the grid x. Description Once it is created.. only specify a subsample value. It will fail if the window does not contain any Continuous Grid layers. if these tables are changed and the 3DMap window is manually “refreshed” or re-created from a workspace. Roll adjusts the camera's current rotation about the z axis centered at the camera's origin. You cannot increase the grid resolution. If there are multiple grids in the Map window.e. FocalPoint indicates the camera/light focal point Orientation specifies the cameras ViewUp (vu_1. Since it is based on the same tables as the original Map window. backgroundcolor is a color to be used to set the background and is specified using the RGB( ) function. If the grid is 200x200 then the resolution values will be clamped to a maximum of 200x200. grid_scale is the amount to scale the grid in the z direction. vpn_3). 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. vpn_2. 189 . All rights reserved. A value >1 will exaggerate the topology in the z direction. The initialization will read in the grid layer to create 3D geometry and topology objects.75) Creates a 3DMap window of the most recent Map window. Example Create Map3D Resolution(75. the 3DMap window is a standalone window. The horizontal angle in the dialog box ranges from 0360 degrees and rotates the maps around the center point of the grid.Create Map3D statement angle is an angle measurement in degrees. 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. unit_name specifies the units the grid values are in.

Creates a 3DMap window with a Red background.100) Scale 2 Background RGB(255. menuitem . 190 © 2006 MapInfo Corporation.0. the z units set to feet. help is a string that appears on the status bar whenever the menu item is highlighted. the Create Menu statement defines an entirely new menu. a Z scale factor of 2. see Alter Menu statement on page 85. to preserve the item's Show/Hide behavior. identifying a standard menu.5 . menu_id is a SmallInt ID number from one to fifteen.0) Units "ft". or a special syntax for handling the menu event by calling OLE or DDE. the menuitem string must start with an exclamation point and include a caret (^).Create Menu statement Create Map3D From Window FrontWindow( ) Resolution(100. For a list of the standard MapInfo Professional menu names. If the newmenuname parameter does not match the name of an existing menu. see Calling Clause Options on page 169. or redefines an existing menu. or a code for a standard menu command. menuitem is a string representing the name of an item to include on the new menu. the statement re-defines that menu. MapBasic 8. See Also Set Map3D statement Create Menu statement Purpose Creates a new menu. and the grid resolution set to 100x100.. If you specify a command code for a standard MapInfo Professional Show/Hide command (such as M_ WINDOW_STATISTICS). Syntax 1 Create Menu newmenuname [ ID menu_id ] As menuitem [ ID menu_item_id ] [ HelpMsg help ] { Calling handler | As menuname } [ . ] Syntax 2 Create Menu newmenuname As Default newmenuname is a string representing the name of the menu to define or redefine. menu_item_id is an integer ID number that identifies a custom menu item. menuname is the name of an existing menu to include as a hierarchical submenu. All rights reserved.. handler is the name of a procedure. Description If the newmenuname parameter matches the name of an existing MapInfo Professional menu (such as File).

The optional ID clause lets you assign a unique integer ID to each custom menu item. Menu item IDs can also be used by other statements. where handler is either the name of a MapBasic procedure or a numeric code identifying an MapInfo Professional operation (such as M_ FILE_SAVE to specify the File > Save command). including the menus defined automatically by MapInfo Professional (File. "Objects" As "Objects" Reference Guide © 2006 MapInfo Corporation. such as the Alter Menu Item statement. you must include an extra back slash in the menuitem string or the help string. Creating Hierarchical Menus To include a hierarchical menu on the new menu. The item whose name starts with @ is the first item in the second column. “Client/Server. use the As sub-clause instead of the Calling subclause. Your program must Include the file MENU. the change will be visible immediately. For example.Create Menu statement The Create Menu statement does not automatically display a newly-created menu. Note: MapInfo Professional can maintain no more than 96 menu definitions at one time. All rights reserved. The As sub-clause must specify the name of the existing menu which should be attached to the new menu. Within the handler procedure. the following statement creates a menu item that reads. If you want to display any of these special characters in the menu or the status bar help.). The menuitem parameter identifies the name of the menu item. If the user chooses a menu item which has a handler. The item's name can contain special control characters to define menu item attributes (for example. However. and if that existing menu is already part of the menu bar. This limit is independent of the number of menus displayed on the menu bar at one time. Assigning Handlers to Custom Menu Items Most menu items include the Calling handler clause. 191 . Create Menu "Special" As "Configure" Calling config_sub_proc. the custom menu breaks into two columns. back slash(\). The following characters require special handling: slash (/). If a menu item has neither a handler nor a menuname associated with it. if a Create Menu statement modifies an existing menu. The following example creates a custom menu containing one conventional menu item and one hierarchical menu. that menu item is inert. such as displaying horizontal lines which break up a menu. Inert menu items are used for cosmetic purposes. See tables below for details. Menu item IDs are useful if you want to allow multiple menu items to call the same handler procedure. you can determine which menu item the user chose by calling CommandInfo(CMD_INFO_MENUITEM).” Create Menu "Data" As "Client\/Server" Calling cs_proc If a menuitem parameter begins with the character @.DEF if you plan to refer to menu codes such as M_FILE_SAVE. whether a menu item is checkable). and less than (<). MapBasic automatically calls the handler (whether the handler is a sub procedure or a command code). a new menu will only display as a result of a subsequent Alter Menu Bar statement or Create Menu Bar statement. etc.

the name of the hierarchical menu appears on the parent menu instead of the menuitem string. Properties of a Menu Item Menu items can be enabled or disabled. the item toggles between alternate text (for example. All rights reserved. Show… vs. Example: !+Confirm Deletions !+ Defining Keyboard Shortcuts Menu items can have two different types of keyboard shortcuts. It may only appear once in the menu system. but it is initially unchecked. and it may not be used on a shortcut menu. the user can press Alt-W to show the Window menu. Example: !Confirm Deletion ($ (> ! ! … ^ … If a caret (^) appears within the text string of a checkable menu item. One type of keyboard shortcut lets the user drop down a menu or choose a menu item by pressing keys. 192 © 2006 MapInfo Corporation.5 . MapBasic 8. include control codes (from the table below) at the start of the menuitem parameter. Some menu items are checkable. a checkable menu item is either checked or unchecked. Control code ( (- Effect The menu item is initially disabled. and it is initially checked. To eliminate the MRU list from the File menu. For example. Example: (This special code represents the File menu's most-recently-used (MRU) list.” Example: !Hide Status Bar^Show Status Bar Menu item is checkable. such a menu item cannot have a handler. either delete this code from MAPINFOW. At any given time. on MapInfo Professional.MNU or re-create the File menu by issuing a Create Menu statement. meaning that the menu can display a check mark next to the item.Create Menu statement When you add a hierarchical menu to the menu. The text before the caret appears when the item is “checked. It may only appear once in the menu system. To create this type of keyboard shortcut. Hide…) instead of toggling between checked and unchecked. Example: (Close The menu item is a horizontal separator line. which let the user choose menu items through the keyboard rather than by clicking with the mouse. disabled items appear grayed out. then press M (or Alt-M) to choose New Map Window. Menu item is checkable. This special code represents the Window menu's list of open windows. To set the properties of a menu item.

193 . Note: The codes in the following tables must appear at the end of a menu item name. Note: The Create Menu Bar As Default statement removes and un-defines all custom menus created through the Create Menu statement. use the following key sequences. you can restore the menu to its original state by issuing a Create Menu menuname As Default statement. the accelerator code must include a percent sign (%) followed by a number. Place the ampersand immediately before the character to be used as the shortcut. Examples: Zap /W^Z or Zap /W^%120 To specify a function key as a Windows accelerator. The number 112 corresponds to F1. Windows Accelerator Code /W {letter | %number} Effect Defines a Windows shortcut key which can be activated by pressing the appropriate key. Alternately. Reference Guide © 2006 MapInfo Corporation. Examples: Zap /WZ or Zap /W%120 /W# {letter | %number} Defines a Windows shortcut key which also requires the shift key. If a menu item has a shortcut key sequence of Alt-F5. of the custom menus that your application has added. “File”). specify “&Map” as the menuitem parameter in the Create Menu statement). etc. After altering a standard MapInfo Professional menu (for example. Examples: Zap /W@Z or Zap /W@%120 /W^ {letter | %number} Defines a Windows shortcut key which also requires the Ctrl key. if you need to un-define one. 113 corresponds to F2. Examples: Zap /W#Z or Zap /W#%120 /W@ {letter | %number} Defines a Windows shortcut key which also requires the Alt key. but not all. the user can activate the menu item by pressing Alt-F5. you can issue a statement of the form Create Menu menuname As Default. All rights reserved. The other type of keyboard shortcut allows the user to activate an option without going through the menu at all. To create this type of shortcut.Create Menu statement include the ampersand character (&) in the newmenuname or menuitem string (for example.

"topic" In the last two cases. MapInfo Professional handles the event by running a standard MapInfo Professional menu command (the File > New command. MapBasic 8.Create Menu statement Calling Clause Options The Calling clause specifies what should happen when the user chooses the custom menu command. ID 7 Alter Menu Bar Add "DataEntry". and then adds the custom menu. ID 7 End Sub 194 © 2006 MapInfo Corporation. "Edit" Calling editsub. The following table describes the available syntax.5 . and Help. in this example). If you specify a procedure name. Calling my_procedure Calling OLE "methodname" Calling DDE "server". Calling clause example Calling M_FILE_NEW Description If Calling is followed by a numeric code from MENU. MapInfo Professional handles the event by connecting through DDE to “server|topic” and sending an Execute message to the DDE server. This technique guarantees that the last two menus will always be Window. MapInfo Professional handles the event by making a method call to the OLE Automation object set by the SetCallback method. the Window menu. Examples The following example uses the Create Menu statement to create a custom menu. see the MapBasic User Guide. MapInfo Professional handles the event by calling the procedure. ID 6. 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 Professional). Windows only. The remainder of the string contains a comma-separated list of the values returned from relevant CommandInfo( ) function calls.DEF. then adds the custom menu to MapInfo Professional's menu bar. and the Help menu back to the menu bar. This example removes the Window menu (ID 6) and the Help menu (ID 7). For complete details on the string syntax. Declare Declare Declare Declare Sub Sub Sub Sub Main addsub editsub delsub Sub Main Create Menu "DataEntry" As "Add" Calling addsub. "Delete" Calling delsub Alter Menu Bar Remove ID 6. All rights reserved.

"(Print" Calling M_FILE_PRINT. 1 for the File menu) Reference Guide © 2006 MapInfo Corporation. Note that both the Open and Save options use the Chr$(9) function to insert a Tab character into the menu item name. and define the menu as just a separator control code: “(-”. "(Close" Calling M_FILE_CLOSE. Save. "Open" +Chr$(9)+"Ctrl+O/W^O" Calling M_FILE_OPEN. Include "MENU. use a Create Menu statement to re-create the appropriate menu. so that the remaining text is shifted to the right. "(Save" +Chr$(9)+"Ctrl+S /W^S" Calling M_FILE_SAVE. menu_number is the number associated with a standard MapInfo Professional menu (for example..DEF" Create Menu "File" As "New" Calling M_FILE_NEW. All rights reserved. The “(” control character specifies that the Close. or the name of a custom menu created through a Create Menu statement.Create Menu Bar statement The following example creates an abbreviated version of the File menu. "Exit" Calling M_FILE_EXIT If you want to prevent the user from having access to MapInfo Professional's shortcut menus. "(-". respectively). Syntax 1 Create Menu Bar As { menu_name | ID menu_number } [ . The following example uses this technique to disable the Map window's shortcut menu.. ] Syntax 2 Create Menu Bar As Default menu_name is the name of a standard MapInfo Professional menu. 195 . The Open and Save options have Windows accelerator key sequences (Ctrl+O and Ctrl+S. using the available menus. "(-". Create Menu "MapperShortcut" As "(-" See Also Alter Menu Item statement. { menu_name | ID menu_number } . and Print options will be disabled initially. Create Menu Bar statement Create Menu Bar statement Purpose Rebuilds the entire menu bar. "(-".

called DataEntry. However. the resultant menu may be shorter than the standard MapInfo Professional menu. Create Menu Bar As "File". “File”). and window-specific (for example. Create Menu Bar As "File". for example. the following statement: Create Menu Bar As Default restores the standard MapInfo Professional menu bar. "Edit". Edit. For the sake of not accidentally disabling other MapBasic applications. After the menu bar has been customized. the File menu has an ID of 1. etc. If the statement omits one or more of the standard menu names. See Alter Menu statement on page 85 for a listing of the names and ID numbers of MapInfo Professional's menus. "Query". the Create Menu Bar statement can create a menu bar that is longer than the standard MapInfo Professional menu. the MapInfo Professional menu bar only displays a Map menu when a Map window is the active window. and in what order. and DataEntry menus. All rights reserved. "Browse" The following example creates a custom menu. Edit. Any menu can be identified by its name (for example. MapBasic 8. 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. Each of MapInfo Professional's standard menus can also be referred to by its menu ID. if the statement includes the names of one or more custom menus (which were created through the Create Menu statement).5 . "Query". Similarly. 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. all items on the Map menu will be disabled (grayed out) whenever the current window is not a Map window. Query. "Map". regardless of whether it is a standard menu or a custom menu. "WinSpecific" Ordinarily. even when no windows are on the screen. Map. Declare Sub AddSub Declare Sub EditSub Declare Sub DelSub Create Menu "DataEntry" As 196 © 2006 MapInfo Corporation. and then redefines the menu bar so that it includes only the File. Conversely. "Edit".Create Menu Bar statement Description A Create Menu Bar statement tells MapInfo Professional which menus should appear on the menu bar. Browse.) menus. MapInfo Professional 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. and all items on the Browse menu will be disabled whenever the current window is not a Browse window.

y1 ) ( x2. see RGB( ) function on page 483. Currently MapInfo Professional uses the following four different syntaxes to define a symbol used for points: Syntax 2 (MapInfo 3.. x y specifies the location of the point. "Edit" calling EditSub.0 symbols refers to the symbol set that was originally published with MapInfo for Windows 3. size is an integer point size.. but the user can customize the symbol set by using the Symbol application. The standard set of symbols includes symbols 31 through 67. Syntax Create Multipoint [ Into { Window window_id | Variable var_name } ] [ num_points ] ( x1..Create MultiPoint statement "Add" calling AddSub.0 and has been maintained in subsequent versions of MapInfo Professional. color is an integer RGB color value. color. Reference Guide © 2006 MapInfo Corporation. size ) shape is an integer. "Delete" calling DelSub Create Menu Bar As "File". To create an invisible symbol. specifying which character to use from MapInfo Professional's standard symbol set.. The Multipoint object displays in the Browser as a single record. The Symbol clause specifies a symbol style. "Edit". ] window_id is a window identifier. ] [ Symbol. 197 . var_name is the name of an existing object variable. from 1 to 48. Note: One symbol is used for all points contained in a Multipoint object. Menu Bar statement Create MultiPoint statement Purpose Combines a number of points into a single object. All points have the same symbol. 31 or larger. y2 ) [ .0 Symbol Syntax) Symbol ( shape. All rights reserved. Create Menu statement. MapInfo 3. "DataEntry" See Also Alter Menu Bar statement. num_points is the number of points inside Multipoint object. use 31.

specifying which character to use from a TrueType font. customstyle ) filename is a string up to 31 characters long.3) 198 © 2006 MapInfo Corporation. size. Syntax 5 Symbol symbol_expr symbol_expr is a Symbol expression. rotation is a floating-point number representing a rotation angle. fontstyle. See table below. color.Create MultiPoint statement Syntax 3 (TrueType Font Syntax) Symbol ( shape. “Wingdings”). for example.1) (2. the MakeSymbol( ) function. fontname is a string representing a TrueType font name (for example.1) (3. size.-2) (4. Syntax 4 (Custom Bitmap File Syntax) Symbol ( filename. MapBasic 8. representing the name of a bitmap file. color. size is an integer point size. All rights reserved. customstyle is an integer code controlling color and background attributes. in degrees. from 1 to 48.0) (1.4) (-1. To create an invisible symbol. which can either be the name of a Symbol variable. Example Create Multipoint 7 (0. 31 or larger.5 . color is an integer RGB color value. use 31. color is an integer RGB color value. see RGB( ) function on page 483. or a function call that returns a Symbol value. rotation ) shape is an integer. see RGB( ) function on page 483. from 1 to 48. The file must be in the CUSTSYMB directory (unless a Reload Symbols statement has been used to specify a different directory). fontstyle is an integer code controlling attributes such as bold. size is an integer point size. fontname.2) (3.

.... 199 . All rights reserved. Syntax 1 Create Object As { Buffer | Union | Intersect | Merge | ConvexHull | Voronoi } From fromtable [ Into { Table intotable | Variable varname } ] [ Data column = expression [ . varname is the name of an Object variable where a new object will be stored.Create Object statement Create Object statement Purpose Creates one or more regions by performing a Buffer. ] ] [ Group By { column | RowID } ] Syntax 2 (Buffer-specific) Create Object As Buffer From fromtable [ Into { Table intotable | Variable varname } ] [ Width bufferwidth [ Units unitname ]]] [ Type { Spherical | Cartesian } ] ] [ Resolution smoothness ] [ Data column = expression [ .. ] ] [ Group By { column | RowID } ] Syntax 3 (Isogram-specific) Create Object As Isogram From fromtable [ Into { Table intotable } ] [ Data column = expression [ . Voronoi.. Merge. Intersect.. Union.. column = expression. time2 [ Brush brushclause ] [ Pen penclause ]] [. or Isogram operation. intotable is the name of an open table where the new object(s) will be stored..] Units dist_unit ] [ Time time1 [[ Brush brushclause ] [ Pen penclause ]] [. column = expression. column = expression. timeN [ Brush brushclause ] [ Pen penclause ]] [. dist2 [ Brush brushclause ] [ Pen penclause ]] [. ] ] Connection connection_handle [ Distance dist1 [[ Brush brushclause ] [ Pen penclause ]] [. distN [ Brush brushclause ] [ Pen penclause ] [. Reference Guide © 2006 MapInfo Corporation.. containing one or more graphic objects..] Units time_unit ] fromtable is the name of an open table..

In general. Union. Thus. column is the name of a column in the table. penclause is a valid Pen clause. To store the results in an Object variable. All rights reserved. the end result may be a region object that contains two overlapping polygons. and Isogram are discussed in sections below. Merge. or Isogram) on one or more existing objects. distN are numeric expressions representing distances for the Isograms expressed in dist_units. The Into clause specifies where results are stored. the resulting buffer is smaller than the source object. Specify Intersect to create an object representing the intersection of other objects (for example. Buffer. “km” for kilometers). specify Into Variable. The keyword which follows the As keyword dictates what type of objects are created. dist_unit is a valid unit of distance. If you omit the Into clause. Voronoi. If the original objects overlap. results are stored in the source table. 200 © 2006 MapInfo Corporation. by performing a geographic operation (Buffer. “min”. time1. indicating the number of segments per circle in a Buffer operation. the merge operation does not eliminate the overlap. and if the source object is a closed object. brushclause is a valid Brush clause. the intersection is the area covered by both objects). specify Into Table. time2. To store the results in a table. Intersect. See Set Distance Units statement on page 570 for a complete list of possible values. The Merge operation produces a results object that contains all of the polygons that belonged to the original objects. Specify Merge to create an object representing the combined area of the source objects. Note: If you specify a Group By clause to perform data aggregation. MapBasic 8. expression is an expression used to populate column. if you merge two overlapping regions (each of which contains one polygon). ConvexHull. polyline. if this number is negative. you must store the results in a table rather than a variable. Union should be used instead. or “sec”. If the width is negative. if two regions overlap. arc) or a point.5 . and the object is a linear object (line. connection_handle is a number expression returned from the Open Connection statement referencing the connection to be used. ConvexHull. Valid choices are: “hr”. smoothness is an integer from 2 to 100. dist_unit is the name of a distance unit (for example. then the absolute value of width is used to produce a positive buffer. Description The Create Object statement creates one or more new region objects. timeN are numeric values representing times for Isograms expressed in time_units. dist1.Create Object statement bufferwidth is a number indicating the displacement used in a Buffer operation. time_unit is a string representing valid unit of time. dist2.

Merge) on the group. which eliminates any areas of overlap. MapInfo Professional performs data aggregation. If the statement includes a Group By clause. The optional Units subclause lets you specify a distance unit name (such as “km” for kilometers) to apply to the Width Reference Guide © 2006 MapInfo Corporation. MapInfo Professional creates one combined object for all objects in the table. but they behave very differently in cases where objects are completely contained within other objects. or Points in the fromtable. The data values from the original input points can be assigned to the resultant polygon for that point by specifying data clauses. In this case. If a Create Object As Union statement does not include a Group By clause. For example. it does not delete the input objects. it must name a column in the table to allow MapInfo Professional to group the source objects according to the contents of the column and produce a combined object for each group of objects. Polylines. The convex hull polygon can be thought of as an operator that places a rubber band around all of the points. The union operation does not remove the area of the smaller object. MapInfo Professional creates one convex hull polygon. If you specify a Data clause. the end result may be a region object that contains one polygon. The union and merge operations are similar. Combining using a Target and potentially different tables is only available with the Objects Combine statement. If you specify a Group By clause. Specify Voronoi to create regions that represent the Voronoi solutions of the input points. The Width clause specifies the width of the buffer. If the statement includes a Group By RowID clause. Create Objects As Union only inserts the new combined object. then creates one convex hull polygon for each group of objects. If a Create Object As ConvexHull statement does not include a Group By clause. the merge operation removes the area of the smaller object from the larger object. 201 . you may want to use the Data clause to assign data values based on the Sum( ) or Avg( ) aggregate functions. It consists of the minimal set of points such that all other points lie on or inside the polygon. If you perform the union operation on two overlapping regions (each of which contains one polygon). The points used to construct the convex hull are any nodes from Regions. MapInfo Professional groups the source objects according to the contents of the column. The polygon is convex—no interior angle can be greater than 180 degrees. leaving a hole where the smaller object was. Create Objects As Union is similar to the Objects Combine statement. if you perform merge or union operations. If the statement includes a Group By clause that names a column in the table. and performs an operation (for example. Buffer If the Create Object statement performs a Buffer operation. MapInfo Professional creates one convex hull polygon for each object in the source table. the statement can include Width and Resolution clauses. MapInfo Professional groups all records sharing the same value. The Objects Combine statement deletes the input and inserts a new combined object. All rights reserved. Convex Hull The ConvexHull operator creates a polygon representing a convex hull around a set of points. The Combine Objects using Column functionality is only available using Create Objects As Union using the Group By clause.Create Object statement Specify Union to perform a combine operation.

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. then creates one buffer region for each group of objects. If the statement includes a Group By clause which names a column in the table. If the statement includes a Group By RowID clause. If the Cartesian type is used. with each one having an optional Brush clause and/or Pen clause. then Spherical calculations are used regardless of the Type setting. MapBasic uses miles as the distance unit. You must specify a Distance clause or a Time clause to create the size of the Isogram desired. If the Width clause does not include the Units sub-clause. If a Create Object As Buffer statement does not include a Group By clause. If the Width clause does not include the Type sub-clause. If the Spherical type is used. but in general. If the data is in a NonEarth projection. you can produce smoother buffer regions. Many items factor into the equation. MapBasic 202 © 2006 MapInfo Corporation. the longer the Create Object statement takes. the buffer width is interpreted in MapBasic's current distance unit. that the larger the smoothness value. then the default distance calculation type Spherical is used. then calculations are performed using Spherical methods regardless of the option chosen. By specifying a larger smoothness value. then the calculations are performed using Cartesian methods regardless of the option chosen.5 . If you do not specify a Brush clause or Pen clause the current brush and pen is used. to change this unit. the Cartesian calculations are used regardless of the Type setting. MapInfo Professional groups the source objects according to the contents of the column. Note that if the coordinate system of the intotable is NonEarth. MapInfo Professional creates one buffer region. you can create regions based on time. Larger values take substantially longer to create. 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 Resolution keyword lets you specify the number of segments comprising each circle of the buffer region. By default. The Distance clause can contain one or more distance expressions with an optional brush and/or pen for each one.Create Object statement clause. All rights reserved. then the calculation is done by mapping the data into a Latitude/Longitude On Earth projection and using widths measured using Spherical distance calculations. MapBasic 8. By default. The maximum amount of values allowed is 50. and if the coordinate system of the intotable is Latitude/Longitude. meaning that there are twelve segments in a simple ring-shaped buffer region. a buffer object has a smoothness value of twelve (12). MapInfo Professional creates one buffer region for each object in the source table. Isogram If the Create Object statement performs an Isogram operation. Each value creates a separate band that can be either specific times or specific distances. using the Set Connection Isogram statement with MajorRoadsOnly specified. 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 data is in a Latitude/Longitude projection. and the more disk space the resultant object occupies. By specifying a Time clause. you must pass a connection_handle that corresponds to an open connection created with an Open Connection statement. use the Set Distance Units statement. results in a much quicker response compared to using the entire road network. It can either be Spherical or Cartesian. Type is the method used to calculate the buffer width around the object. however. Note. The optional Type sub-clause lets you specify the type of distance calculation used to create the buffer.

Each group consists of all parcels having the same value in the zone_id column. A subsequent Update statement or Insert statement could then copy the object to a table. similarly. then performs one merge operation for each group. representing a quarter-mile buffer around whatever objects are currently selected. and stores the resultant regions in the table Zones. the maximum time is 2 hours with MajorRoadsOnly Off and 8 hours with MajorRoadsOnly On. Create Object As ConvexHull from state_caps into Table dump_table See Also Buffer( ) function. Open Table "PARCELS" Open Table "ZONES" Create Object As Merge From PARCELS Into Table ZONES Data parcelcount=Count(*). Objects Combine statement. Dim corridor As Object Create Object As Buffer From Selection Into Variable corridor Width 0. 203 .zonevalue=Sum(parcelvalue) Group By zone_id The next example creates a region object. Open Connection statement Reference Guide © 2006 MapInfo Corporation. Objects Intersect statement. Objects Erase statement. The zonevalue column in the Zones table indicates the sum of the values from the parcels that comprised that zone.25 Units "mi" Resolution 60 The next example shows a multi-object convex hull using the Create Object As statement. The buffer object is stored in the Object variable.Create Object statement only allows distances of 150 miles with MajorRoadsOnly Off and 600 miles with MajorRoadsOnly On. Since the Create Object statement includes a Group By clause. Following the Create Object statement. ConvexHull( ) function. All rights reserved. Thus. the parcelcount column in the Zones table indicates how many parcels were merged to produce that zone. the Zones table ends up with one region object for each group of objects in the Parcels table. corridor. MapBasic groups the Parcel regions. Example The following example merges region objects from the Parcels table.

If you need to create objects on a Layout window.. Objects created on a Layout window. Syntax Create Pline [ Into { Window window_id | Variable var_name } ] [ Multiple num_sections ] num_points ( x1. num_points specifies how many nodes the polyline will contain.Create Pline statement Create Pline statement Purpose Creates a polyline object. use Create Pline to create an object with no nodes. If you need to create a polyline object. If the Into clause specifies a Window identifier. and then use the Alter Object statement to add detail to the polyline object. the object will be stored in the specified object variable. All rights reserved. y1 ) ( x2. however. To use a different paper unit. ] [ Pen. the Create Pline statement will use the current line style (the style which appears in the MapInfo Professional Options > Line Style dialog box). MapBasic 8. The optional Pen clause specifies a line style.. The Pen clause specifies a line style. 204 © 2006 MapInfo Corporation. use the Set Paper Units statement. the object will be stored in the appropriate place in the window (for example. see Set CoordSys statement on page 566 for more information). the limit is smaller: for each additional section. ] [ Smooth ] window_id is a window identifier. y2 ) [ . If the statement includes the optional Into Variable clause. If you omit the Into clause. in the editable layer of a Map window). var_name is the name of an existing object variable.5 . A single-section polyline can contain up to 32. you must first issue a Set CoordSys Layout statement. see Pen clause on page 446 for more details. but do not know until run-time how many nodes the object should contain. y pair defines a node of the polyline. See Alter Object statement on page 92 for more information. create the object in two steps: First. each x. num_sections specifies how many sections the multi-section polyline will contain. MapInfo Professional attempts to store the object in the topmost window. Smooth will smooth the line so that it appears to be one continuous line with curves instead of angles. By default. MapBasic uses inches as the paper unit.. are specified in paper units.763 nodes. no object is created. Description The Create Pline statement creates a polyline object. For a multiple-section polyline. If no Pen clause is specified. The x and y parameters use whatever coordinate system MapBasic is currently using (Longitude/ Latitude by default. reduce the number of nodes by three.. if objects cannot be stored in the topmost window.

Examples The following example uses the Insert statement to insert a new row into the table Sites. which has an optional Symbol clause. Longitude). 42. Insert statement. Pen clause. MapBasic uses a Longitude/Latitude coordinate system. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system.4) ) Reference Guide © 2006 MapInfo Corporation. or inserted into a new row of a table (through an Insert statement). Note: If you need to create objects on a Layout window. Open Table "sites" Insert Into sites (obj) Values ( CreatePoint(-72.CreatePoint( ) function See Also Alter Object statement. The x and y parameters should use whatever coordinate system MapBasic is currently using. you must first issue a Set CoordSys statement. 205 . To create a point object with a specific Symbol style. The point object created through the CreatePoint( ) function could be assigned to an Object variable. By default. you could issue a Create Point statement.5. representing a y-position (for example. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window. Return Value Object Description The CreatePoint( ) function returns an Object value representing a point. All rights reserved. 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. stored in an existing row of a table (through the Update statement). Latitude). Update statement CreatePoint( ) function Purpose Returns an Object value representing a point. Alternately. The point object will use whatever Symbol style is currently selected. y is a float value. y ) x is a float value. instead of calling CreatePoint( ). you could issue the Set Style statement before calling CreatePoint( ). Syntax CreatePoint( x. representing an x-position (for example.

Description The Create Point statement creates a point object. not whole degrees.5 ..Create Point statement The following example assumes that the table Sites has Xcoord and Ycoord columns. If the Into clause specifies a window identifier. Ycoord columns. Each point object will be located at the position indicated by the Xcoord. ycoord) The above example assumes that the Xcoord. which indicate the longitude and latitude positions of the data. most MapInfo for DOS pointfiles store longitude coordinates in the “NorthWest quadrant. If the statement includes the optional Into Variable clause. y specifies the location of the point. The Update statement uses the CreatePoint( ) function to build a point object for each row in the table. Also. Following the Update operation. Open Table "sites" Update sites Set obj = CreatePoint(xcoord. All rights reserved. x. the object will be stored in the specified object variable.. Insert statement. Note that MapInfo for DOS pointfiles store coordinates in millionths of degrees.ycoord/1000000) See Also Create Point statement. MapBasic 8. The Symbol clause specifies a symbol style. y ) [ Symbol. each row in the Sites table will have a point object attached. Thus. and multiply the Xcoord field by negative one: Open Table "sites" Update sites Set obj = CreatePoint(-xcoord/1000000. in the editable layer of a Map window). ] window_id is a window identifier. If the Into 206 © 2006 MapInfo Corporation. Update statement Create Point statement Purpose Creates a point object.” meaning that longitudes increase as you move westward. the object will be stored in the appropriate place in the window (for example. var_name is the name of an existing object variable. you would need to divide the Xcoord and Ycoord fields by one million. Ycoord columns contain actual longitude and latitude degree values. Syntax Create Point [ Into { Window window_id | Variable var_name } ] ( x. to perform the Update operation on a MapInfo for DOS pointfile.

Objects created on a Layout window. An error message is displayed if a layer with regions is not found. vu_2. 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. vpn_1. z ) | FocalPoint ( x. vpn_2. see Symbol clause on page 651 for more details. layer_id is the layer identifier of a layer in the map (one or larger). MapBasic uses inches as the default paper unit. If no Symbol clause is specified. mapper_creation_string specifies a command string that creates the mapper textured on the Prism map. you must first issue a Set CoordSys Layout statement. vu_3. if objects may not be stored in the topmost window (for example. The x and y parameters use whatever coordinate system MapBasic is currently using. MapBasic uses a longitude. however. if the topmost window is a grapher) no object will be created. By default. 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. y. y. The optional Symbol clause specifies a symbol style. z ) ] | [ Orientation(vu_1. All rights reserved. Insert statement. while each y-coordinate represents the distance from the top edge of the page. See Also CreatePoint( ) function. layer_name is the name of a layer in the map. Reference Guide © 2006 MapInfo Corporation.Create PrismMap statement clause is not provided. the Create Point statement uses the current symbol style (the style which appears in the Options > Symbol Style dialog box). MapBasic will attempt to store the object in the topmost window. vpn_3. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window. Symbol clause. Note: If you need to create objects on a Layout window. latitude coordinate system. By default. clip_near. 207 . To use a different paper unit. are specified in paper units: each x-coordinate represents a distance from the left edge of the page. Update statement Create PrismMap statement Purpose Creates a Prism map. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. use the Set Paper Units statement.

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. vpn_3) and Clipping Range (clip_near and clip_far). Roll adjusts the camera's current rotation about the z-axis centered at the camera's origin. For example. The Create PrismMap statement corresponds to MapInfo Professional's Map > Create Prism Map menu item. angle is an angle measurement in degrees. Description The Create PrismMap statement creates a Prism Map window. a value <1 will scale down the topological features in the z direction. used specifically for persistence of view). A value >1 will exaggerate the topology in the z direction. if no window_id is provided. you could create a map. vu_2. even if the Map window has only one layer. The layer may be identified by 208 © 2006 MapInfo Corporation. The Prism Map is a way to associate multiple variables for a single object in one visual. MapInfo Professional chooses each object's display style based on that record's expr value.WOR). to see an example of the Create PrismMap statement. Position indicates the camera and/or light position. You could then copy the Create PrismMap statement in your MapBasic program. MapInfo Professional preserves Prism Maps settings by storing a Create PrismMap statement in the workspace file. ViewPlane Normal (vpn_1. Orientation specifies the camera's ViewUp (vu_1. 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. vu_3). All rights reserved. Each Create PrismMap statement must specify an expr expression clause. save the workspace (for example. PRISM. The expression typically includes the names of one or more columns from the table being shaded. Camera specifies the camera position and orientation. The optional window_id clause identifies which map layer to use in the prism map. The horizontal angle in the dialog box ranges from 0360 degrees and rotates the maps around the center point of the grid. MapBasic uses the topmost Map window. Pitch adjusts the camera's current rotation about the x-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. vpn_2. Thus.Create PrismMap statement expr is an expression that is evaluated for each row in the table. MapInfo Professional evaluates this expression for each object in the layer. backgroundcolor is a color to be used to set the background and is specified using the RGB( ) function. and examine the workspace in a MapBasic text edit window. The Create PrismMap statement must specify which layer to use. MapBasic 8. FocalPoint indicates the camera and/or light focal point. Similarly.5 . choose the Map > Create Thematic Map command. you can see examples of the Create PrismMap statement by opening the MapBasic Window before you choose Map > Create Thematic Map. grid_scale is the amount to scale the grid in the z direction. Between sessions. Yaw adjusts the camera's current rotation about the y-axis centered at the camera's origin. following the Create PrismMap 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 table is the name of the table to be shaded thematically.192) See Also Set PrismMap statement. expr is an expression that is evaluated for each row in the table. For an introduction to thematic maps. Alternately. see the MapInfo Professional documentation. where the topmost map layer has a layer_id value of one. which can then be used in a Shade statement.Create Ranges statement number (layer_id). the Create PrismMap statement can identify the map layer by name (for example. Reference Guide © 2006 MapInfo Corporation. array_variable is the float array variable in which the range information will be stored. num_ranges specifies the number of ranges (default is 4). 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). the next layer has a layer_id value of two.192. rounding_factor is factor by which the range break numbers should be rounded (for example. “world”). etc. 10 to round off values to the nearest ten). Example Open Table "STATES. q_expr is the expression used to perform quantiling. All rights reserved.TAB" Interactive Map From STATES Create PrismMap From Window FrontWindow( ) STATES With Pop_1980 Background RGB(192. 209 . PrismMapInfo( ) function Create Ranges statement Purpose Calculates thematic ranges and stores the ranges in an array.

this example creates a set of five ranges. 0-25. Quantiled ranges are best illustrated by example. After calling Create Ranges. You do not need to pre-size the array.1). If you specify “Equal Count” the ranges are constructed so that there are approximately the same number of rows in each range. call the Shade statement to create the thematic map. Because of the Quantile Using Pop_1990 clause. The final size of the array is twice the number of ranges. 75100). and states with the lowest BPI values will be placed in the lowest range (the palest color). using a method that takes state population (Pop_1990) into account. MapInfo Professional divides that total by the number of ranges (in this case.Create Ranges statement The optional Use clause specifies how to break the data into ranges. The Shade statement usually specifies the same table name and column expression as the Create Ranges statement. MapInfo Professional uses the population standard deviation (N . If you specify “Equal Ranges” each range covers an equal portion of the spectrum of values (for example. if necessary. five ranges). the Use clause is ignored and range limits are defined according to the q_expr. 210 © 2006 MapInfo Corporation. Quantiled Ranges If the optional Quantile Using clause is present. but does not exceed. MapInfo Professional then tries to define the ranges in such a way that the total population for each range approximates. The following statement creates ranges of buying power index (BPI) values. MapBasic 8. to make room for the range information. Because of the With BPI_1990 clause. If you specify “StdDev” the middle range breaks at the mean of your data values. for the United States. At that time. 25-50. states with the highest BPI values will be placed in the highest range (the deepest color). MapInfo Professional calculates the total 1990 population for the table (which. and uses state population statistics to perform quantiling to set the range limits. MapInfo Professional assigns rows to the first range until adding another row would cause the cumulative population to match or exceed fifty million. MapInfo Professional automatically enlarges the array.5 . Create Ranges From states With BPI_1990 Quantile Using Pop_1990 Number 5 Into Variable f_ranges Because of the Number 5 clause. and use the Shade statement's optional From Variable clause to read the array of ranges. and the ranges above and below the middle range are one standard deviation above or below the mean. because MapInfo Professional calculates a high value and a low value for each range. If you specify “Natural Break” the ranges are dictated by natural breaks in the set of data values. The Into Variable clause specifies the name of the float array variable that will hold the range information. starting with the states having low BPI values. is roughly 250 million). fifty million. MapInfo Professional retrieves rows from the States table in order of BPI values. All rights reserved. producing a result of fifty million. 50-75. the range limits for the intermediate ranges are calculated by quantiling. Since the Quantile Using clause specifies the Pop_1990 column.

0) 'style for LOW range To Brush (2. brush_styles( ) As Brush Dim col_name As Alias Open Table "states" Interactive Create Styles From Brush(2. Set Shade statement. Shade statement Reference Guide © 2006 MapInfo Corporation. 211 . BLUE. etc. MapInfo Professional places rows in the second range until adding another row would cause the cumulative total to match or exceed 100 million.def" Dim range_limits( ) As Float. Example Include "mapbasic. 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" Create Ranges From states With col_name Use "Natural Break" Number 5 Into Variable range_limits Map From states Shade states With col_name Ranges From Variable range_limits Style Variable brush_styles ' Show the theme legend window: Open Window Legend See Also Create Styles statement.Create Ranges statement MapInfo Professional considers the first range “full” and then assigns rows to the second range. CYAN. All rights reserved. at that point. the second range is full.

All rights reserved.. The optional Pen clause specifies a line style. ] [ Brush. If the Into clause is not provided.5 . Description If the Create Rect statement includes the optional Into Variable clause. the optional Brush clause specifies a fill style. If no Pen clause is specified. To use a different paper unit. The x and y parameters use whatever coordinate system MapBasic is currently using. 212 © 2006 MapInfo Corporation. you must first issue a Set CoordSys Layout statement. call the Set Paper Units statement. MapBasic uses inches as the default paper unit. MapBasic will attempt to store the object in the topmost window. however. Note: If you need to create objects on a Layout window. ] window_id is a window identifier. Objects created on a Layout window. in the editable layer of a Map window). while each y-coordinate represents the distance from the top edge of the page. y2 ) [ Pen. MapBasic uses a Longitude/Latitude coordinate system. Syntax Create Rect [ Into { Window window_id | Variable var_name } ] ( x1. var_name is the name of an existing object variable. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. if objects may not be stored in the topmost window (for example. y2 specifies the opposite corner of the rectangle. the object will be stored in the specified object variable. see Brush clause on page 109 for more details. are specified in paper units: each x-coordinate represents a distance from the left edge of the page. if the topmost window is a grapher) no object will be created. see Pen clause on page 446 for more details. y1 ) ( x2. x2.. The Pen clause specifies a line style. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window. MapBasic 8..Create Rect statement Create Rect statement Purpose Creates a rectangle or square object. If the Into clause specifies a Window identifier. the Create Rect statement uses the current line style (the style which appears in the Options > Line Style dialog box). y1 specifies the starting corner of the rectangle. the object will be stored in the appropriate place in the window (for example. x1. By default. Similarly. The Brush clause specifies a fill style.. By default.

This statement corresponds to choosing MapInfo Professional's Window > New Redistrict Window command. The Brush keyword specifies that the Districts Browser will show each district's fill style. see the MapInfo Professional documentation. Description The Create Redistricter statement begins a redistricting session. Syntax Create Redistricter source_table By district_column With [ Count ] [ . use the Set Redistricter statement. { Sum | Percent } ( expr ) ] [ . Pen ] [ . The Percentage From clause specifies in-row calculation. or based on most-recently-used). MapInfo Professional stores the object's new district name in this column. Reference Guide © 2006 MapInfo Corporation. and as objects are assigned to different districts. district_column is the name of a column. Create RoundRect statement. Brush ] [ . Insert statement.Create Redistricter statement See Also Brush clause. Pen clause. The Pen keyword specifies that the Districts Browser will show each district's line style. use the Close Window statement to close the Districts Browser window. Update statement Create Redistricter statement Purpose Begins a redistricting session. 213 .. ] [ Percentage From expr] [ Order { "MRU" | "Alpha" | "Unordered" } ] source_table is the name of the table containing objects to be grouped into districts. For an introduction to redistricting. The Order clause specifies the order of rows in the Districts Browser (alphabetical. To control the set of districts. Symbol ] [ . All rights reserved.. { Sum | Percent } ( expr ) . The Count keyword specifies that the Districts Browser will show a count of the objects belonging to each district. the initial set of districts is built from the original contents of this column. unsorted. expr is a numeric column expression. To end the redistricting session. default is MRU. The Symbol keyword specifies that the Districts Browser will show each district's symbol style.

the keyword Brush appears by itself. ] . num_points1 specifies the number of nodes in the region's first polygon. MapBasic 8. symbol. and/or pen styles. etc.. Similarly.. ] [ Center ( center_x. y pair specifies one node of a polygon. Each x.. the user can change a district's style by clicking on the style sample that appears in the Districts Browser. center_y is the y-coordinate of the object centroid. num_polygons specifies the number of polygons that will make up the region (zero or more). var_name is the name of an existing object variable. The Percentage From clause allows you to specify the in-row mode of percentage calculation... ] [ Pen. If the Districts Browser includes brush. The Pen clause specifies a line style.Create Region statement If you include the Brush keyword. ] ] [ num_points2 ( x1. the Districts Browser includes a sample of each district's fill style... See Also Set Redistricter statement Create Region statement Purpose Creates a region object. y2 ) [ .. ] [ Brush. center_x is the x-coordinate of the object centroid. the in-column method of calculation is used.5 . The Brush clause specifies a fill style. If the Percentage From clause is not specified. All rights reserved. 214 © 2006 MapInfo Corporation. num_points2 specifies the number of nodes in the region's second polygon.. the Symbol and Pen keywords are individual keywords. center_y ) ] window_id is a window identifier. Syntax Create Region [ Into { Window window_id | Variable var_name } ] num_polygons [ num_points1 ( x1. y1 ) ( x2. not a complete Symbol clause or Pen clause. Note that this is not a complete Brush clause. y1 ) ( x2.. y2 ) [ .

To use a different paper unit.000 polygons per region (multipolygon region). All rights reserved. y(100) As Float Dim i. the object will be stored in the specified object variable. Depending on your application. but it will not be known until run-time how many nodes or how many polygons the regions will contain. call the Set Paper Units statement. first using Create Region to create an object with no polygons. in the editable layer of a Map window). If the Into clause specifies a window identifier. while each y-coordinate represents the distance from the top edge of the page. The x and y parameters use whatever coordinate system MapBasic is currently using. the Create Region statement uses the current line style (the style which appears in the Options > Line Style dialog box). Objects created on a Layout window. the limit is smaller: for each additional polygon. Example Dim obj_region As Object Dim x(100). If the Into clause is not provided. You can then use the Alter Object statement to add details to the region. if the topmost window is a grapher) no object will be created. See Alter Object statement on page 92 for more information. For a multiple-polygon region. reduce the number of nodes by three. however.048.Create Region statement Description The Create Region statement creates a region object.572 nodes. are specified in paper units: each x-coordinate represents a distance from the left edge of the page. Note: If you need to create objects on a Layout window. A single-polygon region can contain up to 1. Similarly. you must use the Alter Object statement to add the variable numbers of nodes. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. There can be a maximum of 32. the object will be stored in the appropriate place in the window (for example. the following statements ' will create a region object that has a node Reference Guide © 2006 MapInfo Corporation. you may need to create a region object in two steps. the optional Brush clause specifies a fill style. By default. if objects may not be stored in the topmost window (for example. 215 . see Pen clause on page 446 for more details. The optional Pen clause specifies a line style used to draw the outline of the object. If you specify a num_polygons parameter with a value of zero. If the statement includes the optional Into Variable clause. MapBasic uses inches as the default paper unit. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window. MapBasic will attempt to store the object in the topmost window. To use a different paper unit. MapBasic uses a Longitude/Latitude coordinate system. node_count As Integer ' If you store a set of coordinates in the ' x( ) and y( ) arrays. By default. see Brush clause on page 109 for more details. and then using the Alter Object statement to add details to the region object. If no Pen clause is specified. you must first issue a Set CoordSys Layout statement. If your application needs to create region objects. The num_polygons parameter specifies the number of polygons which comprise the region object. the object will be created as an empty region (a region with no polygons).

You cannot create a report from a grid or raster table. Syntax Create RoundRect [ Into { Window window_id | Variable var_name } ] ( x1. Interactive mode is implied if the Into clause is missing. y(i) ) Next ' Now store the object in the Sites table: Insert Into Sites (Object) Values (obj_region) See Also Alter Object statement. ] 216 © 2006 MapInfo Corporation. you will get an error. Brush clause. create an empty region object Create Region Into Variable obj_region 0 ' Now add nodes to populate the object: For i = 1 to node_count Alter Object obj_region Node Add ( x(i).. ] [ Brush. See Also Open Report statement Create RoundRect statement Purpose Creates a rounded rectangle object.5 . The Interactive keyword signifies that the new report should immediately be loaded into the Crystal Report Designer module. Update statement Create Report From Table statement Purpose Creates a report file for Crystal Reports from an open MapInfo Professional table: Syntax Create Report From Table tablename [Into reportfilespec][Interactive] tablename is an open table in MapInfo Professional. y1 ) ( x2. All rights reserved. MapBasic 8..Create Report From Table statement ' at each x. Insert statement. reportfilespec is a full path and filename for the new report file.. Pen clause.y location: ' First. y2 ) rounding [ Pen..

Description The Create RoundRect statement creates a rounded rectangle object (a rectangle with rounded corners). By default.. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window.. Create Rect statement... rounding is a float value. the optional Brush clause specifies a fill style. | Brush. By default... | Symbol. x2.. To use a different paper unit.. Note: If you need to create objects on a Layout window. y1 specifies one corner of the rounded rectangle. inches on a Layout or degrees on a Map). see Brush clause on page 109 for more details. are specified in paper units: each x-coordinate represents a distance from the left edge of the page. see Pen clause on page 446 for more details. The x and y parameters use whatever coordinate system MapBasic is currently using. x1. | Symbol. specifying the diameter of the circle which fills the rounded rectangle's corner. although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. 217 . you must first issue a Set CoordSys Layout statement. y2 specifies the opposite corner of the rectangle. All rights reserved.. however. } To { Pen. MapBasic uses inches as the default paper unit. The optional Pen clause specifies a line style used to draw the outline of the object. } Vary { Color By { "RGB" | "HSV" } | Background By { "RGB" | "HSV" } | Reference Guide © 2006 MapInfo Corporation. call the Set Paper Units statement. Pen clause. Similarly. the Create RoundRect statement uses the current line style (the style which appears in the Options > Line Style dialog box)..Create Styles statement window_id is a window identifier. If no Pen clause is specified. The Brush clause specifies a fill style. in coordinate units (for example. Update statement Create Styles statement Purpose Builds a set of Pen. | Brush.. Insert statement. Objects created on a Layout window. Brush or Symbol styles. The Pen clause specifies a line style. var_name is the name of an existing object variable. Syntax Create Styles From { Pen. while each y-coordinate represents the distance from the top edge of the page.. See Also Brush clause. and stores the styles in an array. MapBasic uses a Longitude/Latitude coordinate system.

Create Styles statement Size By { "Log" | "Sqrt" | "Constant" }} [ Number num_styles ] [ Inflect At range_number With { Pen... | Brush... | Symbol...} ] Into Variable array_variable num_styles is the number of drawing styles (for example, the number of fill styles) to create. The default number is four. range_number is a SmallInt range number; the inflection attribute is placed after this range. array_variable is an array variable that will store the range of pens, brushes, or symbols.

Description
The Create Styles statement defines a set of Pen, Brush, or Symbol styles, and stores the styles in an array variable. The array can then be used in a Shade statement (which creates a thematic map layer). For an introduction to thematic mapping, see the MapInfo Professional documentation. The From clause specifies a Pen, Brush, or Symbol style. If the array of styles is later used in a thematic map, the From style is the style assigned to the “low” range. The To clause specifies a style that corresponds to the “high” range of a thematic map. The Create Styles statement builds a set of styles which are interpolated between the From style and the To style. For example, the From style could be a Brush clause representing a deep, saturated shade of blue, and the To style could be a Brush clause representing a pale, faint shade of blue. In this case, MapInfo Professional builds a set of Brush styles that vary from pale blue to saturated blue. The optional Number clause specifies the total number of drawing styles needed; this number includes the two styles specified in the To and From clauses. Usually, this corresponds to the number of ranges specified in a subsequent Shade statement. The Vary clause specifies how to spread an attribute among the styles. To spread the foreground color, use the Color sub-clause. To spread the background color, use the Background sub-clause. In either case, color can be spread by interpolating the RGB or HSV components of the From and To colors. If you are creating an array of Symbol styles, you can use the Size sub-clause to vary the symbols' point sizes. Similarly, if you are creating an array of Pen styles, you can use the Size subclause to vary line width. The optional Inflect At clause specifies an inflection attribute that goes between the From and To styles. If you specify an Inflect At clause, MapInfo Professional creates two sets of styles: one set of styles interpolated between the From style and the Inflect style, and another set of styles interpolated between the Inflect style and the To style. For example, using an inflection style, you could create a thematic map of profits and losses, where map regions that have shown a profit appear in various shades of green, while regions that have shown a loss appear in various shades of red. Inflection only works when varying the color attribute. The Into Variable clause specifies the name of the array variable that will hold the styles. You do not need to pre-size the array; MapInfo Professional automatically enlarges the array, if necessary, to make room for the set of styles. The array_variable (Pen, Brush, or Symbol) must match the style type specified in the From and To clauses.

218
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

Create Table statement

Example
The following example demonstrates the syntax of the Create Styles statement. Dim brush_styles( ) As Brush 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 This Create Styles statement defines a set of five Brush styles, and stores the styles in the b_ ranges array. A subsequent Shade statement could create a thematic map which reads the Brush styles from the b_ranges array. For an example, see Create Ranges statement on page 209.

See Also
Create Ranges statement, Set Shade statement, Shade statement

Create Table statement
Purpose
Creates a new table.

Syntax
Create Table table ( column columntype [ , ... ] ) | Using from_table } [ File filespec ] [ { Type NATIVE | Type DBF [ CharSet char_set ] | Type { Access | ODBC } database_filespec [ Version version ] Table tablename [ Password pwd ] [ CharSet char_set ] } ] [ Version version ] table is the name of the table as you want it to appear in MapInfo Professional. column is the name of a column to create. Column names can be up to 31 characters long, and can contain letters, numbers, and the underscore (_) character. Column names cannot begin with numbers. from_table is the name of a currently open table in which the column you want to place in a new table is stored. The from_table must be a base table, and must contain column data. Query tables and raster tables cannot be used and will produce an error. The column structure of the new table will be identical to this table. filespec specifies where to create the .TAB, .MAP, and .ID files (and in the case of Access, .AID files). If you omit the File clause, files are created in the current directory.
Reference Guide © 2006 MapInfo Corporation. All rights reserved.

219

Create Table statement char_set is the name of a character set; see CharSet clause on page 125. database_filespec is a string that identifies a valid Access database. If the specified database does not exist, MapInfo Professional creates a new Access .MDB file. 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) or 3.0 (for Access '95/'97). If omitted, the default version is 4.0. If the database in which the table is being created already exists, the specified database version is ignored. tablename is a string that indicates the name of the table as it will appear in Access. pwd is the database-level password for the database, to be specified when database security is turned on. version is 100 (to create a table that can be read by versions of MapInfo Professional) or 300 (MapInfo Professional 3.0 format). Does not apply when creating an Access table; the version of the Access table is handled by DAO. columntype is the data type associated with the column. Each columntype is defined as follows: Char( width ) | Float | Integer | SmallInt | Decimal( width, decplaces ) | Date | Logical width indicates how large each field should be (does not apply to all field types). Char fields can have a width of up to 254 characters. decplaces indicates the number of decimal places to use in a decimal field.

Description
The Create Table statement creates a new empty table with up to 250 columns. Specify ODBC to create new tables on a DBMS server. The Using clause allows you to create a new table as part of the “Combine Objects Using Column” functionality. The from_table must be a base table, and must contain column data. Query tables and raster tables cannot be used and will produce an error. The column structure of the new table being created will be identical to this table. The optional File clause specifies where to create the new table. If no File clause is used, the table is created in the current directory or folder. The optional Type clause specifies the table's data format. The default type is NATIVE, but can alternately be DBF. The NATIVE format takes up less disk space than the DBF format, but the DBF format produces base files that can be read in any dBASE-compatible database manager. Also, create new tables on DBMS Servers from the ODBC Type clause in the Create Table statement. The CharSet clause specifies a character set. The char_set parameter should be a string constant, such as “WindowsLatin1”. If no CharSet clause is specified, MapBasic uses the default character set for the hardware platform that is in use at runtime. See CharSet clause on page 125 for more information. The SmallInt column type reserves two bytes for each value; thus, the column can contain values from -32,767 to +32,767. The Integer column type reserves four bytes for each value; thus, the column can contain values from -2,147,483,647 to +2,147,483,647.

220
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

CreateText( ) function The Version clause controls the table's format. If you specify Version 100, MapInfo Professional creates a table in a format that can be read by versions of MapInfo Professional. If you specify Version 300, MapInfo Professional creates a table in the format used by MapInfo Professional 3.0. 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 created in the version 300 format.

Example
The following example shows how to create a table called Towns, containing 3 fields: a character field called townname, an integer field called population, and a decimal field called median_income. The file will be created in the subdirectory C:\MAPINFO\DATA. Since an optional Type clause is used, the table will be built around a dBASE file. Create Table Towns ( townname Char(30), population SmallInt, median_income Decimal(9,2) ) File "C:\MAPINFO\TEMP\TOWNS" Type DBF

See Also
Alter Table statement, Create Index statement, Create Map statement, Drop Table statement, Export statement, Import statement, Open Table statement

CreateText( ) function
Purpose
Returns a text object created for a specific map window.

Syntax
CreateText( window_id, x, y, text, angle, anchor, offset ) window_id is an integer window identifier that represents a Map window. x, y are float values, representing the x/y location where the text is anchored. text is a string value, representing the text that will comprise the text object. angle is a float value, representing the angle of rotation; for horizontal text, specify zero. anchor is an integer value from 0 to 8, controlling how the text is placed relative to the anchor location. Specify one of the following codes; codes are defined in MAPBASIC.DEF. LAYER_INFO_LBL_POS_CC LAYER_INFO_LBL_POS_TL LAYER_INFO_LBL_POS_TC LAYER_INFO_LBL_POS_TR LAYER_INFO_LBL_POS_CL LAYER_INFO_LBL_POS_CR
Reference Guide © 2006 MapInfo Corporation. All rights reserved.

(0) (1) (2) (3) (4) (5)

221

Create Text statement LAYER_INFO_LBL_POS_BL (6) LAYER_INFO_LBL_POS_BC (7) LAYER_INFO_LBL_POS_BR (8) The two-letter suffix indicates the label orientation: T=Top, B=Bottom, C=Center, R=Right, L=Left. For example, to place the text below and to the right of the anchor location, specify the define code LAYER_INFO_LBL_POS_BR, or specify the value 8. offset is an integer from zero to 200, representing the distance (in points) the text is offset from the anchor location; offset is ignored if anchor is zero (centered).

Return Value
Object

Description
The CreateText( ) function returns an Object value representing a text object. The text object uses the current Font style. To create a text object with a specific Font style, issue the Set Style statement before calling CreateText( ). At the moment the text is created, the text height is controlled by the current Font. However, after the text object is created, its height depends on the Map window's zoom; zooming in will make the text appear larger. The object returned could be assigned to an Object variable, stored in an existing row of a table (through the Update statement), or inserted into a new row of a table (through an Insert statement).

Example
The following example creates a text object and inserts it into the map's Cosmetic layer (given that the variable i_map_id is an integer containing a Map window's ID). Insert Into Cosmetic1 (Obj) Values ( CreateText(i_map_id, -80, 42.4, "Sales Map", 0,0,0) )

See Also
AutoLabel statement, Create Text statement, Font clause, Insert statement, Update statement

Create Text statement
Purpose
Creates a text object, such as a title, for a Map or Layout window.

Syntax
Create Text [ Into { Window window_id | Variable var_name } ] text_string ( x1, y1 ) ( x2, y2 )

222
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

CurDate( ) function [ [ [ [ [ Font... ] Label Line { Simple | Arrow } ( label_x, label_y ) ] Spacing { 1.0 | 1.5 | 2.0 } ] Justify { Left | Center | Right } ] Angle text_angle ]

window_id is an integer window ID number, identifying a Map or Layout window. var_name is the name of an existing object variable. text_string specifies the string, up to 255 characters long, that will constitute the text object; to create a multiple-line text object, embed the function call Chr$(10) in the string. x1, y1 are floating-point coordinates, specifying one corner of the rectangular area which the text will fill. x2, y2 specify the opposite corner of the rectangular area which the text will fill. The Font clause specifies a text style. The point-size element of the Font is ignored if the text object is created in a Map window; see below. label_x, label_y specifies the position where the text object's label line is anchored. text_angle is a float value indicating the angle of rotation for the text object (in degrees).

Description
The x and y parameters use whatever coordinate system MapBasic is currently using. By default, MapBasic uses a Longitude/Latitude coordinate system, although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. If you need to create objects on a Layout window, you must first issue a Set CoordSys Layout statement. The x1, y1, x2, and y2 arguments define a rectangular area. When you create text in a Map window, the text fills the rectangular area, which controls the text height; the point size specified in the Font clause is ignored. In a Layout window, text is drawn at the point size specified in the Font clause, with the upper-left corner of the text placed at the (x1, y1) location; the (x2, y2) arguments are ignored.

See Also
AutoLabel statement, CreateText( ) function, Font clause, Insert statement, Update statement

CurDate( ) function
Purpose
Returns the current date in YYYYMMDD format.

Syntax
CurDate( )

Return Value
Date
Reference Guide © 2006 MapInfo Corporation. All rights reserved.

223

CurrentBorderPen( ) function

Description
The Curdate( ) function returns a Date value representing the current date. The format will always be YYYYMMDD. To change the value to a string in the local system format use the FormatDate$( ) function or Str$( ) function.

Example
Dim d_today As Date d_today = CurDate( )

See Also
Day( ) function, Format$( ) function, Month( ) function, StringToDate( ) function, Timer( ) function, Weekday( ) function, Year( ) function

CurrentBorderPen( ) function
Purpose
Returns the current border pen style currently in use.

Syntax
CurrentBorderPen( )

Return Value
Pen

Description
The CurrentBorderPen( ) function returns the current border pen style. MapInfo Professional assigns the current style to the border of any region objects drawn by the user. If a MapBasic program creates an object through a statement such as Create Region statement, but the statement does not include a Pen clause, the object uses the current BorderPen style. The return value can be assigned to a Pen variable, or may be used as a parameter within a statement that takes a Pen setting as a parameter (such as Set Map statement). To extract specific attributes of the Pen style (such as the color), call the StyleAttr( ) function. For more information about Pen settings, see Pen clause on page 446.

Example
Dim p_user_pen As Pen p_user_pen = CurrentBorderPen( )

See Also
CurrentPen( ) function, Pen clause, Set Style statement, StyleAttr( ) function

224
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

CurrentBrush( ) function

CurrentBrush( ) function
Purpose
Returns the Brush (fill) style currently in use.

Syntax
CurrentBrush( )

Return Value
Brush

Description
The CurrentBrush( ) function returns the current Brush style. This corresponds to the fill style displayed in the Options > Region Style dialog box. MapInfo Professional assigns the current Brush value to any filled objects (ellipses, rectangles, rounded rectangles, or regions) drawn by the user. If a MapBasic program creates a filled object through a statement such as the Create Region statement, but the statement does not include a Brush clause, the object will be assigned the current Brush value. The return value of the CurrentBrush( ) function can be assigned to a Brush variable, or may be used as a parameter within a statement that takes a Brush setting as a parameter (such as Set Map statement or Shade statement). To extract specific Brush attributes (such as the color), call the StyleAttr( ) function. For more information about Brush settings, see Brush clause on page 109.

Example
Dim b_current_fill As Brush b_current_fill = CurrentBrush( )

See Also
Brush clause, MakeBrush( ) function, Set Style statement, StyleAttr( ) function

CurrentFont( ) function
Purpose
Returns the Font style currently in use for Map and Layout windows.

Syntax
CurrentFont( )

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

225

CurrentLinePen( ) function

Return Value
Font

Description
The CurrentFont( ) function returns the current Font style. This corresponds to the text style displayed in the Options > Text Style dialog box when a Map or Layout window is the active window. MapInfo Professional will assign the current Font value to any text object drawn by the user. If a MapBasic program creates a text object through the Create Text statement, but the statement does not include a Font clause, the text object will be assigned the current Font value. The return value of the CurrentFont( ) function can be assigned to a Font variable, or may be used as a parameter within a statement that takes a Font setting as a parameter (such as Set Legend statement). To extract specific attributes of the Font style (such as the color), call the StyleAttr( ) function. For more information about Font settings, see Font clause on page 295.

Example
Dim f_user_text As Font f_user_text = CurrentFont( )

See Also
Font clause, MakeFont( ) function, Set Style statement, StyleAttr( ) function

CurrentLinePen( ) function
Purpose
Returns the Pen (line) style currently in use.

Syntax
CurrentLinePen( )

Return Value
Pen

Description
The CurrentLinePen( ) function returns the current Pen style. MapInfo Professional assigns the current style to any line or polyline objects drawn by the user. If a MapBasic program creates an object through a statement such as Create Line statement, but the statement does not include a Pen clause, the object uses the current Pen style. The return value can be assigned to a Pen variable, or may be used as a parameter within a statement that takes a Pen setting as a parameter (such as Set Map statement). To extract specific attributes of the Pen style (such as the color), call the StyleAttr( ) function. For more information about Pen settings, see Pen clause on page 446.

226
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

CurrentPen( ) function

Example
Dim p_user_pen As Pen p_user_pen = CurrentPen( )

See Also
CurrentBorderPen( ) function, Pen clause, Set Style statement, StyleAttr( ) function

CurrentPen( ) function
Purpose
Returns the Pen (line) style currently in use and sets the border pen to the same style as the line pen.

Syntax
CurrentPen( )

Return Value
Pen

Description
The CurrentPen( ) function returns the current Pen style. MapInfo Professional assigns the current style to any line or polyline objects drawn by the user. If a MapBasic program creates an object through a statement such as the Create Line statement, but the statement does not include a Pen clause, the object uses the current Pen style. If you want to use the current line pen without resetting the border pen, use the CurrentLinePen( ) function. The return value can be assigned to a Pen variable, or may be used as a parameter within a statement that takes a Pen setting as a parameter (such as the Set Map statement). To extract specific attributes of the Pen style (such as the color), call the StyleAttr( ) function. For more information about Pen settings, see Pen clause on page 446.

Example
Dim p_user_pen As Pen p_user_pen = CurrentPen( )

See Also
MakePen( ) function, Pen clause, Set Style statement, StyleAttr( ) function

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

227

CurrentSymbol( ) function

CurrentSymbol( ) function
Purpose
Returns the Symbol style currently in use.

Syntax
CurrentSymbol( )

Return Value
Symbol

Description
The CurrentSymbol( ) function returns the current symbol style. This is the style displayed in the Options > Symbol Style dialog box. MapInfo Professional assigns the current Symbol style to any point objects drawn by the user. If a MapBasic program creates a point object through a Create Point statement, but the statement does not include a Symbol clause, the object will be assigned the current Symbol value. The return value of the CurrentSymbol( ) function can be assigned to a Symbol variable, or may be used as a parameter within a statement that takes a Symbol clause as a parameter (such as Set Map statement or Shade statement). To extract specific attributes of the Symbol style (such as the color), call the StyleAttr( ) function. For more information about Symbol settings, see Symbol clause on page 651.

Example
Dim sym_user_symbol As Symbol sym_user_symbol = CurrentSymbol( )

See Also
MakeSymbol( ) function, Set Style statement, StyleAttr( ) function, Symbol clause

228
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

DateWindow( ) function

DateWindow( ) function
Purpose
Returns the current date window setting as an integer in the range 0 to 99, or (-1) if date windowing is off.

Syntax
DateWindow( context ) context is a SmallInt that can either be DATE_WIN_CURPROG or DATE_WIN_SESSION.

Description
This depends on which context is passed. If context is DATE_WIN_SESSION, then the current session setting in effect is returned. If context is DATE_WIN_CURPROG, then the current MapBasic program's local setting is returned, if a program is not running the session setting is returned. MBXs compiled before v5.5 will still convert 2-digit years to the current century (5.0 and earlier behavior). To get the new behavior, they must be recompiled with MapBasic v5.5 or later.

Example
In the following example the variable Date1 = 19890120, Date2 = 20101203 and MyYear = 1990. DIM DIM Set Set Date1, Date2 as Date MyYear As Integer Format Date "US" Date Window 75 Date1 = StringToDate("1/20/89") Date2 = StringToDate("12/3/10") MyYear = Year("12/30/90")

See Also
Set Date Window statement

Day( ) function
Purpose
Returns the day component from a Date expression.

Syntax
Day( date_expr ) date_expr is a Date expression.

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

229

DDEExecute statement

Return Value
SmallInt from 1 to 31

Description
The Day( ) function returns an integer value from one to thirty-one, representing the day-of-themonth component of the specified date. For example, if the specified date is 12/17/93, the Day( ) function returns a value of 17.

Example
Dim day_var As SmallInt, date_var As Date date_var = StringToDate("05/23/1985") day_var = Day(date_var)

See Also
CurDate( ) function, Month( ) function, Timer( ) function, Year( ) function

DDEExecute statement
Purpose
Issues a command across an open DDE channel.

Syntax
DDEExecute channel, command channel is an integer channel number returned by DDEInitiate( ). command is a string representing a command for the DDE server to execute.

Description
The DDEExecute statement sends a command string to the server application in a DDE conversation. The channel parameter must correspond to the number of a channel opened through a DDEInitiate( ) function call. The command parameter string must represent a command which the DDE server (the passive application) is able to carry out. Different applications have different requirements regarding what constitutes a valid command; to learn about the command format for a particular application, see the documentation for that application.

Error Conditions
ERR_CMD_NOT_SUPPORTED error generated if not running on Windows. ERR_NO_RESPONSE_FROM_APP error if server application does not respond.

230
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

DDEInitiate( ) function

Example
Through MapBasic, you can open a DDE channel with Microsoft Excel as the server application. If the conversation specifies the “System” topic, you can use the DDEExecute statement to send Excel a command string. Provided that the command string is equivalent to an Excel macro function, and provided that the command string is enclosed in square brackets, Excel can execute the command. The example below instructs Excel to open the worksheet “TRIAL.XLS”. Dim i_chan As Integer i_chan = DDEInitiate("Excel", "System") DDEExecute i_chan, "[OPEN(""C:\DATA\TRIAL.XLS"")]"

See Also
DDEInitiate( ) function, DDEPoke statement, DDERequest$( ) function

DDEInitiate( ) function
Purpose
Initiates a new DDE conversation, and returns the associated channel number.

Syntax
DDEInitiate( appl_name, topic_name ) appl_name is a string representing an application name (for example, “MapInfo”). topic_name is a string representing a topic name (for example, “System”).

Return Value
Integer

Description
The DDEInitiate( ) function initiates a DDE (Dynamic Data Exchange) conversation, and returns the number that identifies that conversation's channel. A DDE conversation allows two Microsoft Windows applications to exchange information. Once a DDE conversation has been initiated, a MapBasic program can issue DDERequest$( ) function calls (to read information from the other application) and DDEPoke statements (to write information to the other application). Once a DDE conversation has served its purpose and is no longer needed, the MapBasic program should terminate the conversation through the DDETerminate statement or DDETerminateAll statement. Note: DDE conversations are a feature specific to Microsoft Windows; therefore, MapBasic generates an error if a program issues DDE-related function calls when running on a nonWindows platform. To determine the current hardware platform at run-time, call the SystemInfo( ) function.

Reference Guide © 2006 MapInfo Corporation. All rights reserved.

231

DDEInitiate( ) function The appl_name parameter identifies a Windows application. For example, to initiate a conversation with Microsoft Excel, you should specify the appl_name parameter “Excel.” The application named by the appl_name parameter must already be running before you can initiate a DDE conversation; note that the MapBasic Run Program statement allows you to run another Windows application. Not all Windows applications support DDE conversations. To determine if an application supports DDE conversations, see the documentation for that application. The topic_name parameter is a string that identifies the topic for the conversation. Each application has its own set of valid topic names; for a list of topics supported by a particular application, refer to the documentation for that application. With many applications, the name of a file that is in use is a valid topic name. Thus, if Excel is currently using the worksheet file “ORDERS.XLS”, you could issue the following MapBasic statements: Dim i_chan As Integer i_chan = DDEInitiate("Excel", "C:\ORDERS.XLS") to initiate a DDE conversation with that Excel worksheet. Many applications support a special topic called “System”. If you initiate a conversation using the “System” topic, you can then use the DDERequest$( ) function to obtain a list of the strings which the application accepts as valid topic names (i.e. a list of the files that are currently in use). Knowing what topics are available, you can then initiate another DDE conversation with a specific document. See the example below. The following table lists some sample application and topic names which you could use with the DDEInitiate( ) function.

DDEInitiate( ) call DDEInitiate("Excel", "System")

Nature of conversation DDERequest$( ) function calls can return Excel system information, such as a list of the names of the worksheets in use; DDEExecute statements can send commands for Excel to execute. If wks is the name of an Excel document in use, subsequent DDEPoke statements can store values in the worksheet, and DDERequest$( ) function calls can read information from the worksheet. DDERequest$( ) function calls can provide system information, such as a list of the MapBasic applications currently in use by MapInfo Professional. If mbx is the name of a MapBasic application in use, DDEPoke statements can assign values to global variables in the specified application, and DDERequest$( ) function calls can read the current values of global variables.

DDEInitiate("Excel", wks)

DDEInitiate("MapInfo", "System")

DDEInitiate("MapInfo" mbx)

232
© 2006 MapInfo Corporation. All rights reserved.

MapBasic 8.5

A MapBasic program can carry on multiple conversations at the same time.DDEInitiate( ) function When a MapBasic program issues a DDEInitiate( ) function call.” Within one particular conversation. version 4 or later. "topics") ' ' ' ' ' ' ' ' ' ' ' ' If Excel 4 is running." End Program End If Reference Guide © 2006 MapInfo Corporation. in the case of Excel 5. topiclist might look like: ": Sheet1 System" (if spreadsheet is still "unnamed"). The other Windows application is known as the “server. 1) = ":" Then ' . extract just the first topic (for example." Next. topiclist might look like: "[Book1]Sheet1 [Book2]Sheet2 . Chr$(9) ) If tab_marker = 0 Then Note "No Excel documents in use! Stopping. ERR_INVALID_CHANNEL error generated if the specified channel number is invalid. tab_marker = InStr(3.XLS Sheet1 System" If Excel 5 is running. or. etc. we will not overwrite its current contents. Dim chan_num. the MapBasic program is known as the “client” in the DDE conversation. A MapBasic application could act as the client in one conversation (by issuing statements such as DDEInitiate( ).) while acting as the server in another conversation (by defining a RemoteMsgHandler procedure). topicname. limited only by memory and system resources." End Program End If ' Get a list of Excel's valid topics topiclist = DDERequest$(chan_num. "System") If chan_num = 0 Then Note "Excel is not responding to DDE conversation.. topiclist. by extracting the text that appears before the first tab.or like: ": C:Orders. The goal is to store a simple text message (“Hello from MapInfo!”) in the first cell of a worksheet that Excel is currently using. All rights reserved. Error Conditions ERR_CMD_NOT_SUPPORTED error generated if not running on Windows. the client is always the active party."Sheet1") by extracting the text between the 1st & 2nd tabs.then it's Excel 4. tab_marker As Integer Dim topiclist. but only if that cell is currently empty. Example The following example attempts to initiate a DDE conversation with Microsoft Excel. 233 .. cell As String chan_num = DDEInitiate("EXCEL". the server merely responds to actions taken by the client. If Left$(topiclist. If the first cell is not empty...

Excel might currently be editing a chart (for example. "R1C1".. tab_marker . DDERequest$( ) function.1) End If ' open a channel to the specific document ' (e. ' If cell is blank.R1C1. data channel is an integer channel number returned by the DDEInitiate( ) function. ' If cell isn't blank. topiclist. DDETerminateAll statement DDEPoke statement Purpose Sends a data value to an item in a DDE server application.. DDEPoke statement. itemname. topicname) If chan_num = 0 Then Note "Problem communicating with " + topicname End Program End If ' Let's examine the 1st cell in Excel. 234 © 2006 MapInfo Corporation. cell already contains:" + cell Else DDEPoke chan_num." End If DDETerminateAll Note: This example does not anticipate every possible obstacle. See Also DDEExecute statement. All rights reserved.g.5 . don't alter it ' just display cell contents in a MapBasic NOTE. DDETerminate statement. Chr$(9) ) topicname = Left$( topiclist. 3. "R1C1" ) If cell <> Chr$(13) + Chr$(10) Then Note "Message not sent. "Hello from MapInfo!" Note "Message sent to Excel. tab_marker .. tab_marker = Instr(1. assume it's Excel 5. put a message in the cell. MapBasic 8. For example. Syntax DDEPoke channel."+topicname+ ". "Sheet1") DDETerminate chan_num chan_num = DDEInitiate("Excel".3) Else ' . “Chart1”) instead of a worksheet. in which case we will not be able to reference cell “R1C1”. ' Note that a "Blank cell" gets returned as a ' carriage-return line-feed sequence: ' Chr$(13) + Chr$(10).DDEPoke statement topicname = Mid$(topiclist. cell = DDERequest$( chan_num.

a string of the form R1C1 (for Row 1. to learn what item names are supported by a particular Windows application. "R1C1". 235 . Column 1) is a valid item name. Different DDE applications support different item names. The itemname parameter should identify an item which is appropriate for the specified channel. "Sheet1") DDEPoke i_chan_num. "Hello from MapInfo!" The following example assumes that there is another MapBasic application currently in use— ”Dispatch. In a DDE conversation with Excel. ERR_INVALID_CHANNEL error generated if the specified channel number is invalid. "23 Main St. The example below uses DDEPoke to modify the Address global variable. the following example stores a simple message (“Hello from MapInfo!”) in the first cell of an Excel worksheet. Dim i_chan_num As Integer i_chan_num = DDEInitiate("EXCEL".DDERequest$( ) function itemname is a string value representing the name of an item. refer to the documentation for that application. In a DDE conversation with another MapBasic application. Description The DDEPoke statement stores the data text string in the specified DDE item. DDEInitiate( ) function. i_chan_num = DDEInitiate("MapInfo". "Address". The channel parameter must correspond to the number of a channel which was opened through the DDEInitiate( ) function. DDERequest$( ) function DDERequest$( ) function Purpose Returns a data value obtained from a DDE conversation. the name of a global variable in the application is a valid item name."C:\DISPATCH. Error Conditions ERR_CMD_NOT_SUPPORTED error generated if not running on Windows. All rights reserved. Syntax DDERequest$( channel. Example If Excel is already running." See Also DDEExecute statement.MBX") DDEPoke i_chan_num. itemname ) Reference Guide © 2006 MapInfo Corporation.mbx”—and assumes that the Dispatch application has a global variable called Address. data is a character string to be sent to the item named in the itemname parameter.

The following table lists the topic and item combinations that can be used when conducting a DDE conversation with MapInfo Professional as the server. “TEXT BITMAP …”) wks (name of a worksheet in use) A string of the form R1C1 (for Row 1. All rights reserved. 236 © 2006 MapInfo Corporation. “Formats” returns a list of clipboard formats accepted by Excel (for example. MapBasic 8. Different DDE applications support different item names. Column 1) returns the contents of that cell Note: Through the DDERequest$( ) function. Return Value String Description The DDERequest$( ) function returns a string of information obtained through a DDE conversation. one MapBasic application can observe the current values of global variables in another MapBasic application. “Topics” returns a list of DDE topic names accepted by Excel. the DDERequest$( ) function returns a null string. The channel parameter must correspond to the number of a channel which was opened through the DDEInitiate( ) function. The following table lists some topic and item combinations that can be used when conducting a DDE conversation with Microsoft Excel as the server: Topic name “System” Item names to use with DDERequest$( ) “Systems” returns a list of item names accepted under the “System” topic. to learn what item names are supported by a particular Windows application.DDERequest$( ) function channel is an integer channel number returned by the DDEInitiate( ) function. If the request is unsuccessful. itemname is a string representing the name of an item in the server application. The itemname parameter should identify an item which is appropriate for the specified channel. refer to the documentation for that application.5 . including the names of all open worksheets.

All rights reserved. mbx (name of . "Address") See Also DDEInitiate( ) function Reference Guide © 2006 MapInfo Corporation. "R1C1") The following example assumes that there is another MapBasic application currently in use— ”Dispatch”—and assumes that the Dispatch application has a global variable called Address. “Topics” returns a list of DDE topic names accepted by MapInfo Professional. 237 . Note that this example will only work if Excel is already running. ERR_CANT_INITIATE_LINK error generated if MapBasic cannot link to the topic. ERR_INVALID_CHANNEL error if the specified channel number is invalid. Dim i_chan_num As Integer. “Version” returns the MapInfo version number. specifying the name of a global variable lets DDERequest$( ) return the value of the variable Error Conditions ERR_CMD_NOT_SUPPORTED error generated if not running on Windows. which includes the names of all MapBasic applications currently in use. “Formats” returns a list of clipboard formats accepted by MapInfo Professional (“TEXT”). "Sheet1") s_cell = DDERequest$(i_chan_num. multiplied by 100. s_addr_copy As String i_chan_num = DDEInitiate("MapInfo". Example The following example uses the DDERequest$( ) function to obtain the current contents of the first cell in an Excel worksheet.DDERequest$( ) function Topic name “System” item names to use with DDERequest$( ) “Systems” returns a list of item names accepted under the “System” topic. Dim i_chan_num As Integer Dim s_cell As String i_chan_num = DDEInitiate("EXCEL".MBX in use) “{items}” returns a list of the names of global variables in use by the specified MapBasic application. The example below uses DDERequest$( ) to obtain the current value of the Address global variable."C:\DISPATCH.MBX") s_addr_copy = DDERequest$(i_chan_num.

However.DDETerminate statement DDETerminate statement Purpose Closes a DDE conversation.5 . MapBasic 8. DDETerminateAll statement DDETerminateAll statement Purpose Closes all DDE conversations which were opened by the same MapBasic program. a given MapBasic application may only close the DDE channels which it opened. Example DDETerminate i_chan_num See Also DDEInitiate( ) function. the MapBasic program should terminate the conversation through the DDETerminate statement or the DDETerminateAll statement. Description The DDETerminate statement closes the DDE channel specified by the channel parameter. and each application can open its own DDE channels. All rights reserved. ERR_INVALID_CHANNEL error generated if the specified channel number is invalid. Error Conditions ERR_CMD_NOT_SUPPORTED error generated if not running on Windows. Syntax DDETerminate channel channel is an integer channel number returned by the DDEInitiate( ) function. Syntax DDETerminateAll 238 © 2006 MapInfo Corporation. The channel parameter must correspond to the channel number returned by the DDEInitiate( ) function call (which initiated the conversation). Once a DDE conversation has served its purpose and is no longer needed. A MapBasic application may not close DDE channels which were opened by another MapBasic application. Note: Multiple MapBasic applications can be in use simultaneously.

Restrictions This statement may not be issued from the MapBasic window. However. See Also DDEInitiate( ) function. ] ) As return_type fname is the name by which a function will be called. and each application can open its own DDE channels. arrays and custom Types are allowed. Syntax 2 (external routines in Windows DLLs Declare Function fname Lib "file_name" [ Alias "function_alias" ] ( [ [ ByVal ] parameter As var_type ] [. a given MapBasic application may only close the DDE channels which it opened... Once a DDE conversation has served its purpose and is no longer needed. parameter is the name of a parameter to the function. the MapBasic program should terminate the conversation through the DDETerminate statement or the DDETerminateAll statement. Reference Guide © 2006 MapInfo Corporation.. Error Conditions ERR_CMD_NOT_SUPPORTED error generated if not running on Windows. var_type is a variable type. ] ) As return_type fname is the name of the function. such as integer. Syntax 1 Declare Function fname ([ [ ByVal ] parameter As var_type ] [ . All rights reserved. Accessing external functions (using syntax 2) is platform-dependent. DDETerminate statement Declare Function statement Purpose Defines the name and parameter list of a function.Declare Function statement Description The DDETerminateAll statement closes all open DDE channels which were opened by the same MapBasic application. [ ByVal ] parameter As var_type. A MapBasic application may not close DDE channels which were opened by another MapBasic application. 239 . return_type is a standard scalar variable type. [ ByVal ] parameter As var_type.. Note that multiple MapBasic applications can be in use simultaneously. DLL files may only be accessed by applications running on Windows. arrays and custom Types are not allowed.

MapBasic 8. A MapBasic program can use a Function… End Function statement to create a custom function. see the MapBasic User Guide. If the Declare Function statement includes an Alias clause. If the Declare Function statement declares an external function. return_type is a standard scalar variable type. see Function… End Function statement on page 304. Calling External Functions Using Syntax 2 (above). See the MapBasic User Guide for more information. For information on the differences between by-reference and by-value parameters. the Declare Function statement can include an Alias clause. the function_alias parameter must match the external function's original name.Declare Function statement file_name is the name of a Windows DLL file. var_type is a data type: with Windows DLLs. the file_name parameter must specify the name of the file containing the external function. parameter is the name of a parameter to the function. For more information on creating custom functions. Every function defined in this fashion must be preceded by a Declare Function statement. C or Pascal). The external file must be present at runtime. you can use a Declare Function statement to define an external function. and is stored in a separate file. Description The Declare Function statement pre-declares a user-defined MapBasic function or an external function. the Declare Function statement's fname parameter matches the explicit routine name from the external file. 240 © 2006 MapInfo Corporation. and the fname parameter indicates the name by which MapBasic will call the routine. this can be a standard variable type or a custom Type. All rights reserved. However. function_alias is the original name of the external function. Alternately. An external function is a function that was written in another language (for example. Parameters passed to a function are passed by reference unless you include the optional ByVal keyword. which lets you call the external function by whatever name you choose. the DLL must be compiled with “structure packing” set to the tightest packing. Once you have declared an external function. Ordinarily.5 . Every external function has an explicitly assigned name. The Alias clause lets you override an external function's explicit name. in situations where the explicit name conflicts with the name of a standard MapBasic function. Restrictions on Windows DLL parameters You can pass a custom variable type as a parameter to a DLL. your program can call the external function as if it were a conventional MapBasic function.

CubeRoot.. All rights reserved. Reference Guide © 2006 MapInfo Corporation. Restrictions This statement may not be issued from the MapBasic window. parameter is the name of a sub procedure parameter. Syntax 2 (external routines in Windows DLLs) Declare Sub sub_proc Lib "file_name" [ Alias "sub_alias" ] [ ( [ ByVal ] parameter As var_type [ . DLL files may only be accessed by applications running on Windows. the DLL name.. ] ) ] sub_proc is the name of a sub procedure. ] ) ] sub_proc is the name by which an external routine will be called. which returns the cube root of a number (the number raised to the one-third power). sub_alias is an external routine's original name.. Syntax 1 Declare Sub sub_proc [ ( [ ByVal ] parameter As var_type [ .Declare Sub statement Example The following example defines a custom function. Declare Sub Main Declare Function CubeRoot(ByVal x As Float) As Float Sub Main Note Str$( CubeRoot(23) ) End Sub Function CubeRoot(ByVal x As Float) As Float CubeRoot = x ^ (1 / 3) End Function See Also Declare Sub statement. var_type is a standard data type or a custom Type. parameter is the name of a sub procedure parameter. . Function… End Function statement Declare Sub statement Purpose Identifies the name and parameter list of a sub procedure. . file_name is a string. Accessing external functions (using Syntax 2) is platform-dependent.. 241 .

The file must be present at run-time. All rights reserved. the Declare Sub statement's sub_proc parameter matches the explicit routine name from the external file. result As Float Call Cube(2. The Alias clause lets you override an external routine's explicit name. The Declare Sub statement can include an Alias clause. in situations where the explicit name conflicts with the name of a standard MapBasic function. If the Declare Sub statement declares an external routine. cubed As Float) ' 242 © 2006 MapInfo Corporation. Once you have declared an external routine. you can use a Declare Sub statement to define an external routine. result) ' result now contains the value: 27 (3 x 3 x 3) End Sub Sub Cube (ByVal original As Float. this can be a standard variable type or a custom Type. Ordinarily. Example Declare Sub Main Declare Sub Cube(ByVal original As Float. the sub_alias parameter must match the external routine's original name. Typically. Every external routine has an explicitly assigned name. C or Pascal). Description The Declare Sub statement establishes a sub procedure's name and parameter list. Parameters passed to a procedure are passed by reference unless you include the optional ByVal keyword. Calling External Routines Using Syntax 2 (above). You can pass a custom variable type as a parameter to a DLL. your program can call the external routine as if it were a conventional MapBasic procedure.5 . see Type statement on page 667. and is stored in a separate file. Every procedure defined in this manner must be preceded by a Declare Sub statement. which lets you call the external routine by whatever name you choose. For information on custom variable types.Declare Sub statement var_type is a data type: with Windows DLLs. each Declare Sub statement corresponds to an actual sub procedure which appears later in the same program. For more information on creating procedures. If the Declare Sub statement includes an Alias clause. An external routine is a routine that was written in another language (for example. the DLL must be compiled with “structure packing” set to the tightest packing. and the sub_proc parameter indicates the name by which MapBasic will call the routine. However. MapBasic 8. the file_name parameter must specify the name of the file containing the routine. result) ' result now contains the value: 8 (2 x 2 x 2) x = 1 Call Cube(x + 2. A MapBasic program can use a Sub…End Sub statement to create a procedure. cubed As Float) Sub Main Dim x. see Sub…End Sub statement on page 649.

Syntax Define identifier definition identifier is an identifier up to 31 characters long. All rights reserved. Accordingly. beginning with a letter or underscore (_).tab" Reference Guide © 2006 MapInfo Corporation. you might want to use the following definition: Define PI 3. For the remainder of the program. Sub…End Sub statement Define statement Purpose Defines a custom keyword with a constant value.Define statement ' Cube the "original" parameter value. Examples Your application may need to reference the mathematical value known as Pi. the following statement creates a keyword with a definition including quotes: Define FILE_NAME "World. ' cubed = original ^ 3 End Sub See Also Call statement. and store ' the result in the "cubed" parameter.DEF. whenever MapBasic encounters the same identifier the original definition will be substituted for the identifier. The definition portion of a Define statement can include quotes. see Dim statement on page 254.141593. For a list of reserved keywords. If you use a Define statement to define the keyword FOO. such as Set or Create. Description The Define statement defines a new identifier. which has a value of approximately 3. you could simply type PI wherever you needed to reference the value 3. see the standard MapBasic definitions file. MAPBASIC. definition is the text MapBasic should substitute for each occurrence of identifier.141593. An identifier defined through a Define statement is not case-sensitive. Restrictions You cannot issue a Define statement through the MapBasic window. For examples of Define statements.141593 Following such a definition. For example. your program can refer to the identifier as Foo or foo. 243 . You cannot use the Define statement to re-define a MapBasic keyword.

) Dim s_number As String Dim f_value As Float s_number = "1. regardless of whether the user's computer is set up to use another character as the decimal separator.678”. All rights reserved. Syntax DeformatNumber$ ( numeric_string ) numeric_string is a string that represents a numeric value.5 . Examples The following example calls the Val( ) function to determine the numeric value of a string. This Define provides an easy way of clearing the Message window: Define CLS Print Chr$(12) DeformatNumber$( ) function Purpose Removes formatting from a string that represents a number. Before calling the Val( ) function. Return Value String Description Returns a string that represents a number.4" s_number = DeformatNumber$(s_number) ' the variable s_number now contains the ' string: "1222333.DEF. such as “12. The return value does not include thousands separators. (The string that you pass to the Val( ) function cannot contain comma separators.4" f_value = Val(s_number) Print f_value See Also FormatNumber$( ) function. MAPBASIC. regardless of whether the numeric_string argument included comma separators. Val( ) function 244 © 2006 MapInfo Corporation. this example calls the DeformatNumber$( ) function to remove comma separators from the string.345. The return value uses a period as the decimal separator.222. MapBasic 8.333.DeformatNumber$( ) function The following Define is part of the standard definitions file.

A Delete Object From statement only affects objects or records in a table. Open Table "clients" Delete From clients Commit Table clients The following Delete statement deletes only the object from the tenth row of the table: Open Table "clients" Delete Object From clients Where Rowid = 10 Commit Table clients See Also Drop Map statement. the table still exists. There is an important difference between a Delete Object From statement and a Drop Map statement. A Drop Map statement actually modifies the table structure. MapBasic only deletes the graphical objects that are attached to the table. By default. it does not affect the table structure itself. if the statement includes the optional Object keyword.Delete statement Delete statement Purpose Deletes one or more graphic objects. but it is completely empty . All rights reserved. However. By default. so that graphical objects may not be attached to the table. Examples The following Delete statement deletes all of the records from a table. the Delete statement affects all records in the table. then only the specified row is affected by the Delete statement. Description The Delete statement deletes graphical objects or entire records from an open table. or one or more entire rows.as if the user had just created it by choosing File > New. if the statement includes the optional Where Rowid =…clause. rather than deleting the records themselves. However. Insert statement Reference Guide © 2006 MapInfo Corporation. Syntax Delete [ Object ] From table [ Where Rowid = id_number ] table is the name of an open table. from a table. the Delete statement deletes all records from a table. At the conclusion of this operation. 245 . id_number is the number of a single row (an integer value of one or more).

5 © 2006 MapInfo Corporation. Restrictions You cannot issue a Dialog statement through the MapBasic window. y specifies the dialog box’s initial position. All rights reserved. x. in pixels. in dialog box units (8 dialog box height units represent the height of one character).Dialog statement Dialog statement Purpose Displays a custom dialog box. 246 . Each control_clause can specify one of the following types of controls: • • • • • • • • • • • • • • • Button OKButton CancelButton EditText StaticText PopupMenu CheckBox MultiListBox GroupBox RadioGroup PenPickerm BrushPicker FontPicker SymbolPicker ListBox MapBasic 8. w specifies the width of the dialog.. handler is the name of a procedure to call before the user is allowed to use the dialog box. Syntax Dialog [ Title title ] [ Width w ] [ Height h ] [ Position x. representing distance from the upper-left corner of MapInfo Professional's work area. this procedure is typically used to issue Alter Control statements. if the Position clause is omitted. ] title is a string expression that appears in the title bar of the dialog box. in dialog units (4 dialog height units represent the width of one character). h specifies the height of the dialog box. y ] [ Calling handler ] Control control_clause [ Control control_clause. the dialog box appears centered..

etc.). Thus. To place a control at the upper-left corner of a dialog box. Sizes and Positions of Dialog Boxes and Dialog Box Controls Within the Dialog statement. with subsequent control clauses appearing further down in the dialog box. and lets the user interact with it. by clicking OK or Cancel) before doing anything else in MapInfo Professional. a File > Open dialog box). that control is roughly ten characters wide and 5 characters tall. see the MapBasic User Guide. 247 . or GetSeamlessSheet( ) function). and Width clauses are all optional. For an introduction to custom dialog boxes. FileOpenDlg( ) function. All rights reserved. every dialog box should include an OKButton control and/or a CancelButton control. use xand y-coordinates of zero and zero. see Control PenPicker/BrushPicker/SymbolPicker/FontPicker clause. If you want to display a standard dialog box (for example. A width of four dialog box units equals the width of one character. FileSaveAsDlg( ) function. As a general rule. Note statement. For an introduction to the concepts behind MapBasic dialog boxes. Anything that can appear on a dialog box is known as a control. see Control CheckBox clause on page 147 for a discussion of check-box controls). ProgressBar statement. Height. Each dialog box must contain at least one control (for example. The dialog box is modal. If you omit these clauses.Dialog statement See the separate discussions of those control types for more details (for example. the user must dismiss the dialog box (for example. Individual control clauses are discussed in separate entries (for example. displays it on the screen. and a height of eight dialog box units equals the height of one character. see Control CheckBox clause on page 147. Reference Guide © 2006 MapInfo Corporation. MapBasic places the controls at default positions in the dialog box. Control positions are relative to the upper left corner of the dialog box. for details on Picker controls. sizes and positions are stated in terms of dialog box units. an OKButton control). in other words. The Dialog statement lets you create a custom dialog box. see the MapBasic User Guide. so that the user has a way of dismissing the dialog box. The Position. use one of the following statements or functions: Ask( ) function. if a dialog box control has a height of 40 and a width of 40. Each control_clause can specify one of the following control types: • • • • • • • • • Button / OKButton / CancelButton CheckBox GroupBox RadioGroup EditText StaticText PenPicker / BrushPicker / SymbolPicker / FontPicker ListBox / MultiListBox PopupMenu Description The Dialog statement creates a dialog box. for details on CheckBox controls.

Specifying Hotkeys for Controls When a MapBasic application runs on MapInfo. MapInfo Professional stores the control’s final value in a program variable. the user will continue interacting with the dialog box until one of four things happens: • • • • The user clicks the OKButton control (if the dialog box has one). A hotkey is a convenience allowing the user to choose a dialog box control by pressing key sequences rather than clicking with the mouse. Reading the User’s Input After a Dialog statement. and if the user clicks the OKButton. the final dialog box does not show the ampersand. include two successive ampersand characters in the Title clause: 248 © 2006 MapInfo Corporation. MapInfo Professional only updates the variable after the dialog box terminates. call the ReadControlValue( ) function. If a control specifies the Into clause. To force a dialog box to remain on the screen after the user has clicked OK or Cancel. If the user clicked OK. if you want a button to read “Find & Replace”).Dialog statement Terminating a Dialog Box After a MapBasic program issues a Dialog statement. All rights reserved. by pressing Esc on a dialog box that has a CancelButton).5 . Within the Title clause. the ampersand should appear immediately before the character which is to be used as a hotkey character. include the ampersand character (&) in the title for that control. the following function call returns TRUE: CommandInfo(CMD_INFO_DLG_OK) There are two ways to read values entered by the user: Include Into clauses in the Dialog statement. dialog boxes can assign hotkeys to the various controls. assign a handler procedure to the OKButton or CancelButton control and have that handler issue a Dialog Preserve statement. or call the ReadControlValue( ) function from a handler procedure. MapBasic 8. Thus. or The user otherwise dismisses the dialog box (for example. call the CommandInfo( ) function to determine whether the user clicked OK or Cancel to dismiss the dialog box. If you need to display an ampersand character in a control (for example. Also. The user clicks a control with a handler that issues a Dialog Remove statement. The user clicks the CancelButton control (if the dialog box has one). To read a control's value from within a handler procedure. To specify a hotkey for a control. the following Button clause defines a button which the user can choose by pressing Alt-R: Control Button Title "&Reset" Although an ampersand appears within the Title clause. Note: MapInfo Professional only updates the variable if the user clicks OK.

All rights reserved.. 249 . Examples The following example creates a simple dialog box with an EditText control.. etc. Dialog Title "Search" Control StaticText Title "Enter string to find:" Control EditText Value gs_searchfor 'this is a Global String variable Into gs_searchfor Control OKButton Control CancelButton If CommandInfo(CMD_INFO_DLG_OK) Then ' . Specifying the Tab Order The user can press the Tab key to move the keyboard focus through the dialog box.Dialog statement Title "Find && Replace" If you position a StaticText control just before or above an EditText control. MapBasic places each control in a default position. 2 = partial Dim i_quarter As SmallInt '1=1st qrtr.def" Declare Sub reset_sub ‘resets dialog to default settings Declare Sub ok_sub ' notes values when user clicks OK. Dim sym_variable As Symbol Dialog Title "Map Franchise Locations" Reference Guide © 2006 MapInfo Corporation. change the order of the Control clauses. pressing Tab moves the focus to the fourth control. When the focus is on the third control. none of the Control clauses use the optional Position clause. etc. End If The following program demonstrates the syntax of all of MapBasic's control types. Include "mapbasic. etc. If you want to change the tab order.2=County. Dim i_scope As SmallInt '1=Town. Declare Sub Main Sub Main Dim s_title As String 'the title of the map Dim l_showlegend As Logical 'TRUE means include legend Dim i_details As SmallInt '1 = full details. and the variable ' gs_searchfor contains the text the user entered. In this example.then the user clicked OK. and you define the StaticText control with a hotkey designation. The focus moves from control to control according to the dialog box's tab order. the user is able to jump to the EditText control by pressing the hotkey sequence. therefore. Tab order is defined by the order of the Control clauses in the Dialog statement.

30 Control SymbolPicker Position 95. FY 95" Into s_title ID 1 Position 65.4th Qrtr" Value 4 Into i_quarter ID 4 Position 5. 80 Control ListBox Title "First Qrtr.Towns.Counties.2nd Qrtr. 90 Width 65 Height 35 Control StaticText Title "Scope of Map:" Position 5.&Partial Details" Value 2 Into i_details ID 2 Position 12. 130 Control PopupMenu 250 © 2006 MapInfo Corporation. 80 Control MultiListBox Title "Streets. All rights reserved.Highways. 8 Width 90 Control GroupBox Title "Level of Detail" Position 5.Dialog statement Control StaticText Title "Enter Map Title:" Position 5.States" Value 3 ID 5 Position 95. 42 Width 60 Control StaticText Title "Show Franchises As:" Position 95. 45 Into sym_variable ID 3 Control StaticText Title "Show Results For:" Position 5. 90 Width 65 Height 35 Control StaticText Title "Include Map Layers:" Position 95.3rd Qrtr.5 . 30 Width 70 Height 40 Control RadioGroup Title "&Full Details. 10 Control EditText Value "New Franchises. MapBasic 8.

County.Territory. 165 Calling ok_sub Control CancelButton Position 120. 140 Control Button Title "&Reset" Calling reset_sub Position 10.. 165 Control OKButton Position 65. then the user clicked Cancel.Entire State" Value 2 Into i_scope ID 6 Position 5.. 140 Control CheckBox Title "Include &Legend" Into l_showlegend ID 7 Position 95. then the user clicked OK. you could use Alter Control statements ' to reset the controls to their original state. All rights reserved.. 165 If CommandInfo(CMD_INFO_DLG_OK) Then ' .. place code to handle user clicking OK End Sub Reference Guide © 2006 MapInfo Corporation. End If End Sub Sub reset_sub ' here. Else ' . End Sub Sub ok_sub ' Here. 251 .Dialog statement Title "Town.

MapBasic 8. Syntax Dialog Preserve Restrictions This statement may only be issued from within a sub procedure that acts as a handler for an OKButton or CancelButton dialog box control. All rights reserved. ReadControlValue( ) function Dialog Preserve statement Purpose Reactivates a custom dialog box after the user clicked OK or Cancel. Dialog Preserve statement. FileSaveAsDlg( ) function. You cannot issue this statement from the MapBasic window. Description The Dialog Preserve statement allows the user to resume using a custom dialog box (which was created through a Dialog statement) even after the user clicked the OKButton or CancelButton control. 252 © 2006 MapInfo Corporation. Ask( ) function. See Also Alter Control statement.Dialog Preserve statement The preceding program produces the following dialog box. Note statement. Dialog Remove statement. FileOpenDlg( ) function.5 .

A dialog box disappears automatically after the user clicks on an OKButton control or a CancelButton control. Dialog Remove statement. You cannot issue this statement from the MapBasic window. 253 . the application should reactivate the original dialog box. "Yes". Description The Dialog Remove statement removes the dialog box created by the most recent Dialog statement. Reference Guide © 2006 MapInfo Corporation.Dialog Remove statement The Dialog Preserve statement lets you “confirm” the user's OK or Cancel action. and you want the dialog box to come down if the user double-clicks an item in the list. Example The following procedure could be used as a handler for a CancelButton control. Syntax Dialog Remove Restrictions This statement may only be issued from within a sub procedure that acts as a handler for a dialog box control. For example. if you have a dialog box with a ListBox control. This is useful. It does not remove the dialog box instantaneously. you may wish to display a dialog box asking a question such as “Do you want to lose your changes?” If the user chooses “No” on the confirmation dialog box. ReadControlValue( ) function Dialog Remove statement Purpose Removes a custom dialog from the screen. Note: Dialog Remove signals to remove the dialog box after the handler sub procedure returns. "No") = FALSE Then Dialog Preserve End If End Sub See Also Alter Control statement. Use the Dialog Remove statement (within a dialog box control's handler routine) to remove the dialog box before the user clicks OK or Cancel. if the user clicks Cancel. Dialog statement. All rights reserved. for example. Sub confirm_cancel If Ask("Do you really want to lose your changes?". You can provide this functionality by issuing a Dialog Preserve statement from within the CancelButton control's handler procedure.

. ] var_name is the name of a variable to define.. Syntax Dim var_name [ . Note: MapInfo Professional calls this handler procedure for click events and for double-click events. then the user double-clicked. you can only define one variable per Dim statement.MB. All rights reserved. var_name . It handles the ListBox control in the Named Views dialog box. When the user single-clicks a list item. this handler procedure enables various buttons on the dialog box. ] As var_type . var_name .. this handler uses a Dialog Remove statement to dismiss the dialog box. ' i = ReadControlValue(1) Dialog Remove Call go_to_view(i) End If End Sub See Also Alter Control statement. You cannot define array variables using the MapBasic window. Sub listbox_handler Dim i As SmallInt Alter Control 2 Enable Alter Control 3 Enable If CommandInfo(CMD_INFO_DLG_DBL) = TRUE Then ' ' .. Dialog statement... Dialog Preserve statement.5 .Dim statement Example The following procedure is part of the sample program NVIEWS.. When the user double-clicks a list item.. although a Dim statement within a compiled program may define multiple variables. var_name [ . ] As var_type [ . ReadControlValue( ) function Dim statement Purpose Defines one or more variables. Restrictions When you issue Dim statements through the MapBasic window. MapBasic 8. var_type is a standard or custom variable Type. 254 © 2006 MapInfo Corporation.

in bytes. Variable-length character string.147. Float String String * length Logical Date Object Alias Pen Brush Font Symbol The Dim statement which defines a variable must precede any other statements which use that variable.MB program file). stored in 2 bytes. Reference Guide © 2006 MapInfo Corporation.647 (inclusive). Ellipse.147. Local variables may only be accessed from within the procedure or function that contained the Dim statement. stored in 1 byte: zero=FALSE. Text. Polyline. The following table summarizes the types of variables which you can declare through a Dim statement. Pen (line) style setting.. Brush (fill) style setting. Symbol (point-marker) style setting. Date.Dim statement Description A Dim statement declares one or more variables. non-zero=TRUE. or Frame). one byte for the month. stored in eight-byte IEEE format. up to 32768 bytes). fixed-length strings are padded with trailing blanks. If a Dim statement appears outside of any procedure or function definition. All rights reserved. up to 32768 bytes long. TRUE or FALSE. one byte for the day. stored in four bytes: two bytes for the year. Fixed-length character string (where length dictates the length of the string. 255 . To declare global variables (variables that can be accessed by any procedure or function in any of the modules that make up a project). Module-level variables can be accessed by any procedure or function within a program module (i.483. Rectangle. Column name.647 to +2. Line. within the . use the Global statement. Arc. Whole numbers from -2. the statement defines variables that are module-level in scope. Floating point value. the statement defines variables that are local in scope. stored in 4 bytes. Graphical object (Point. Rounded Rectangle.483.e. Font (text) style setting. If a Dim statement appears within a Sub…End Sub statement or within a Function… End Function statement. Region. Location of Dim Statements and Scope of Variables Variable Type SmallInt Integer Description Whole numbers from -32768 to 32767 (inclusive). Dim statements usually appear at the top of a procedure or function.

Dim statement Declaring Multiple Variables and Variable Types A single Dim statement can declare two or more variables that are separated by commas. you must exercise caution when comparing fixed-length and variable-length string variables. are not padded in this fashion. (This feature makes it easier to format text output in such a way that columns line up). A MapBasic array can have up to 32. All rights reserved. the constant string expression to the right of the equal sign has a maximum length of 256 characters. use the UBound( ) function. In the following program. then assigns a value to the first element in the array: Dim f_stats(10) As Float f_stats(1) = 17. The first element of the array is the element with a subscript of one (as shown in the example above). i_max As Integer. In other words. " In this type of assignment. To re-size an array. pads fixed-length string variables with blanks.5 . To define an array variable. This difference can affect comparisons of strings.. i_min. there is a limit to how long a string constant you can specify in a simple assignment statement. MapBasic 8. like other BASIC languages. The following example performs a simple string variable assignment. use the ReDim statement. then assign a five-character string to that variable. MapBasic. To specify an initial array size.23 The number that appears between the parentheses is known as the subscript.767 items. where a constant string expression is assigned to a string variable: Dim status As String status = "This is a string constant . s_name As String Array Variables MapBasic supports one-dimensional array variables. Variable-length string variables. the array will initially contain no members. add a pair of parentheses immediately after the variable name. You also can define variables of different types within one Dim statement by grouping like variables together. the If…Then statement would determine that the two strings are not equal: Dim s_var_len As String Dim s_fixed_len As String * 10 256 © 2006 MapInfo Corporation. To determine the current size of an array. However. String Variables A string variable can contain a text string up to 32 kilobytes in length.. however. include a constant integer expression between the parentheses. you will not be able to store any data in the array until re-sizing the array with a ReDim statement. the variable will actually be padded with five spaces so that it fills the space allotted. in such a case. and separating the different groups with a comma after the variable type: Dim jointer. The following example declares an array of ten float variables. If the Dim statement does not specify an initial array size. if you define a 10-byte string variable.

257 . if a Dim statement defines a variable called abc. and Do. Variable names can also include the punctuation marks $. Thus. and the underscore character ( _ ). Set. or Abc. and can include letters. but only as the final character in the name. Each variable name can be up to 31 characters long.Dim statement s_var_len = "testing" s_fixed_len = "testing" If s_var_len = s_fixed_len Then Note "strings are equal" ' this won't happen Else Note "strings are NOT equal" ' this WILL happen End If Restrictions on Variable Names Variable names are case-insensitive. such as Open. numbers. MapBasic will generate an error when you compile the program. %. are reserved words which may not be used as variable names. A variable name may not begin with a number. Many MapBasic language keywords. Add Close DDEExecute Alter Commit DDEPoke Browse Create DDETerminate Call DDE DDETerminateAl l Dim ElseIf Exit For Goto Insert Note Pack Put Remove Run Set Declare Do End Export Function Graph Layout Objects Print ReDim Rename Save Delete Drop Error Fetch Get If Map OnError PrintWin Register Resume Seek Dialog Else Event Find Global Import Menu Open ProgressBar Reload Rollback Select Reference Guide © 2006 MapInfo Corporation. The table below summarizes the MapBasic keywords which may not be used as variable names. All rights reserved. If you attempt to define a variable called Set. !. #. the program may refer to that variable as abc. and @. Close. ABC. &.

For example. Type statement. UBound( ) function 258 © 2006 MapInfo Corporation. MapBasic 8. Object and style variables are not automatically initialized. which creates ' a new data type known as Person Type Person Name As String Age As Integer Phone As String End Type ' The next Dim statement creates a Person variable Dim customer As Person ' This Dim creates an array of Person variables: Dim users(10) As Person ' this Dim statement defines an integer variable ' "counter". some BASIC languages assume that any variable named with a dollar sign (for example. In MapBasic. All rights reserved. Variable-length string variables are initialized to an empty string.Name = "Chris" See Also Global statement. and an integer array "counters" : Dim counter.Dim statement Shade Type StatusBar Update Stop While Sub In some BASIC languages. through the Dim statement. LastName$) is a string variable. you can dictate a variable's type by ending the variable with one of the punctuation marks listed above. Initial Values of Variables MapBasic initializes numeric variables to a value of zero when they are defined. You must initialize Object and style variables before making references to those variables. and fixed-length string variables are initialized to all spaces. however.5 . ReDim statement. counters(10) As Integer ' the next statement assigns the "Name" element ' of the first member of the "users" array users(1). Example ' Below is a custom Type definition. you must declare every variable's type explicitly.

specify “mi” as the unit_name parameter. Example Dim dist. Generally.end_x. y1 and y2 are y-coordinates (for example. end_y As Float Open Table "cities" Fetch First From cities start_x = CentroidX(cities. unit_name ) x1 and x2 are x-coordinates (for example. You can reset MapBasic's coordinate system through the Set CoordSys statement. latitude).and y-coordinate parameters must use MapBasic's current coordinate system. MapInfo Professional expects coordinates to use a Longitude/Latitude coordinate system. Syntax Distance ( x1.end_y. unit_name is a string representing the name of a distance unit (for example. MapInfo Professional performs a Cartesian or Spherical operation. Return Value Float Description The Distance( ) function calculates the distance between two locations. a great-circle distance between two points is the distance along the great circle which connects the two points. start_x.Distance( ) function Distance( ) function Purpose Returns the distance between two locations. longitude).obj) end_y = CentroidY(cities. By default. 259 .) For the most part. to obtain a distance in miles. (A great circle is a circle that goes around the earth. Distance( ) returns the great-circle distance between the two points. See Set Distance Units statement on page 570 for the list of available unit names. The x. y2. with the circle's center at the center of the earth. a Cartesian operation is performed."mi") Reference Guide © 2006 MapInfo Corporation. for example. All rights reserved. The function returns the distance measurement in the units specified by the unit_name parameter. end_x. a spherical operation is performed unless the coordinate system is NonEarth. A great-circle distance is the shortest distance between two points on a sphere.obj) Fetch Next From cities end_x = CentroidX(cities. x2. in which case. y1.obj) dist = Distance(start_x. “km”). start_y.obj) start_y = CentroidY(cities.start_y. If the current coordinate system is an earth coordinate system.

MapBasic will execute at most one statement_list from a Do Case statement. If none of the expressions in the first Case case_expr clause equal the do_expr expression. MapBasic will execute that Case's statement_list. in that Do Case tests for the existence of certain conditions. MapBasic executes the statements in that Case's statement_list. (In MapBasic. MapBasic will test each Case case_expr clauses in succession. and then jumps down to the first statement following the End Case statement. MapBasic 8. If one of the expressions in the Case case_expr clause is equal to the value of the do_expr expression. In executing a Do Case statement. that case is considered a match. Set CoordSys statement. Restrictions You cannot issue a Do Case statement through the MapBasic window. Accordingly.. MapBasic tries to find a match in the following Case case_expr clause. ] [ Case Else statement_list ] End Case do_expr is an expression. until one of the cases is a match or until all of the cases are exhausted. Set Distance Units statement Do Case…End Case statement Purpose Decides which group of statements to execute. based on the current value of an expression. Description The Do Case statement is similar to the If…Then statement. case_expr ] statement_list [ Case . ObjectLen( ) function. and then jump immediately down to the first statement following End Case. MapBasic examines the first Case case_expr clause. 260 © 2006 MapInfo Corporation. MapBasic's Do Case statement is analogous to the BASIC language's Select Case statement. Upon finding a matching Case.5 .. Syntax Do Case do_expr Case case_expr [ . and decides which statements to execute (if any) based on the results of the test. case_expr is an expression representing a possible value for do_expr.Do Case…End Case statement See Also Area( ) function. the name of the statement was changed to avoid conflicting with the Select statement). statement_list is a group of statements to carry out under the appropriate circumstances. All rights reserved.

5. etc. 9 msg = "Third Quarter" Case Else msg = "Fourth Quarter" End Case See Also If…Then statement Reference Guide © 2006 MapInfo Corporation. Dim cur_month As Integer. expr4 statement_list2 Case Else statement_list3 End Case would have the same effect as an If…Then statement of this form: If expr1 = expr2 Then statement_list1 ElseIf expr1 = expr3 Or expr1 = expr4 Then statement_list2 Else statement_list3 End If Example The following example builds a text string such as “First Quarter”. depending on the current date.. and if none of the Case case_expr clauses match. none of the cases will match. 3 msg = "First Quarter" Case 4. 6 msg = "Second Quarter" Case 7. All rights reserved. and thus no statement_list will be executed. “Second Quarter”. msg As String cur_month = Month( CurDate( ) ) Do Case cur_month Case 1. 2. 261 . However. then MapBasic will carry out the statement list from the Case Else clause.Do Case…End Case statement If none of the case_expr expressions are equal to the do_expr expression. 8. if a Do Case statement includes a Case Else clause. Note that a Do Case statement of this form: Do Case expr1 Case expr2 statement_list1 Case expr3.

262 © 2006 MapInfo Corporation. the optional Until / While clause may either follow the Do keyword or the Loop keyword. such as Goto statement or Exit Do statement.Do…Loop statement Do…Loop statement Purpose Defines a loop which will execute until a specified condition becomes TRUE (or FALSE). the loop will repeat indefinitely. This is of particular importance during the first iteration of the loop. MapBasic will continue to execute the statement_list until the condition becomes FALSE. In such a case. Description The Do…Loop statement provides loop control. The Exit Do statement halts any Do…Loop immediately (regardless of whether the loop has an Until / While clause). the loop repeatedly executes the statement_list until the Until condition becomes TRUE). All rights reserved. Thus. MapBasic 8.5 . The position of the Until / While clause dictates whether MapBasic tests the condition before or after executing the statement_list. Generally speaking. As indicated above. will be needed to halt or exit the loop. If the condition is TRUE. condition is a conditional expression which controls when the loop terminates. a flow control statement. If the Do…Loop does not contain the optional Until / While clause. a Do…Loop using the above syntax will execute the statement_list at least once. Restrictions You cannot issue a Do Loop statement through the MapBasic window. conversely. Syntax 1 Do statement_list Loop [ { Until | While } condition ] Syntax 2 Do [ { Until | While } condition ] statement_list Loop statement_list is a group of statements to be executed zero or more times. the Do…Loop repeatedly executes the statements in a statement_list as long as a While condition remains TRUE (or. A loop using the following syntax: Do statement_list Loop While condition will execute the statement_list and then test the condition. and resumes program execution with the first statement following the Loop clause.

Do While condition statement_list Loop Example The following example uses a Do…Loop statement to read the first ten records of a table. 263 . Description The Drop Index statement deletes an existing index from an open table. Dim sum As Float. issue a Create Index statement.) Note: MapInfo Professional cannot drop an index if the table has unsaved edits. no save operation is required. The Drop Index statement takes effect immediately. the MapBasic Rollback statement will not undo the effect of a Drop Index statement. All rights reserved.Drop Index statement By contrast.population Fetch Next From world counter = counter + 1 Loop While counter <= 10 See Also Exit Do statement. For…Next statement Drop Index statement Purpose Deletes an index from a table. Reference Guide © 2006 MapInfo Corporation. Use the Commit Table statement to save edits. column is the name of a column in that table. Dropping an index reduces the amount of disk space occupied by a table. Syntax Drop Index table( column ) table is the name of an open table. Similarly. You cannot undo the effect of a Drop Index statement by selecting File > Revert or Edit > Undo. (To re-create that index at a later time. a Do…Loop of the following form will only execute the statement_list if the condition is TRUE. counter As Integer Open Table "world" Fetch First From world counter = 1 Do sum = sum + world.

Description A Drop Map statement deletes all graphical objects (points. You still can browse a table after performing Drop Map. circles. (A subsequent Create Map statement will restore the table's ability to contain graphical objects. Example Open Table "clients" Drop Map clients 264 © 2006 MapInfo Corporation. no save operation is required. a Create Map statement will not restore the graphical objects which were discarded during a Drop Map operation.5 . Similarly. MapBasic 8. The Drop Map statement does not work on linked tables. you should be extremely cautious when using the Drop Map statement. use Delete Object instead of Drop Map. and modifies the table structure so that graphical objects may not be attached to the table. but you intend to attach new graphical objects to the same table. Note: The Drop Map statement takes effect immediately. Open Table "world" Drop Index world(name) See Also Create Index statement Drop Map statement Purpose Deletes all graphical objects from a table. If you wish to delete all of the graphical objects from a table. After performing a Drop Map operation. lines. Accordingly. etc. you will no longer be able to display the corresponding table in a Map window.) from an open table. All rights reserved. the MapBasic Rollback statement will not undo the effect of a Drop Map statement. the Drop Map statement modifies the table's structure so that objects may no longer be associated with the table.Drop Map statement Example The following example deletes the index from the Name field of the World table. You cannot undo the effect of a Drop Map statement by selecting File > Revert or Edit > Undo. however. regions. Cannot be used on linked tables. Syntax Drop Map table table is the name of an open table.) The Drop Map statement does not affect the number of records in a table.

Syntax Drop Table table table is the name of an open table. Description The Drop Table statement completely erases the specified table from the computer's disk. Kill statement Reference Guide © 2006 MapInfo Corporation. combining two other tables (SF_STRT1 and SF_STRT2). So.” For example. you could not delete the SF_STRTS table by using the Drop Table statement. In other words. the MapBasic Rollback statement will not undo the effect of a Drop Table statement. 265 . Create Table statement. a Drop Table operation may have the effect of deleting a file which is used outside of MapInfo Professional. All rights reserved. You should be extremely cautious when using the Drop Table statement. you do not need to use the Drop Table statement to delete temporary tables. Note that if a table is based on a pre-existing database or spreadsheet file. The table must already be open. Select) store results in temporary tables (for example. Note: Many MapInfo table operations (for example. the Drop Table statement will delete the original file as well as the component files which make it a table. You cannot undo the effect of a Drop Table statement by selecting File > Revert or Edit > Undo. a StreetInfo table (such as SF_STRTS) is actually a view. Query1). Similarly. Temporary tables are deleted automatically when you exit MapInfo Professional. no save operation is required.Drop Table statement See Also Create Map statement. The Drop Table statement takes effect immediately. Example Open Table "clients" Drop Table clients See Also Create Table statement. Delete statement Drop Table statement Purpose Deletes a table in its entirety. Delete statement. The Drop Table statement cannot be used to delete a table that is actually a “view.

If you include the Interactive keyword. MapInfo Professional automatically executes any sleeping EndHandler procedures before shutting down. and one or more tables have unsaved edits.End MapInfo statement End MapInfo statement Purpose This statement halts MapInfo Professional. If you omit the Interactive keyword. EndHandler procedure End Program statement Purpose Halts a MapBasic application. MapBasic 8. MapInfo Professional prompts the user to save or discard the unsaved work. which is executed automatically when MapInfo Professional terminates.5 . See Also End Program statement. use the End Program statement. Syntax End Program 266 © 2006 MapInfo Corporation. Restrictions The End Program statement may not be issued from the MapBasic window. However. this prompt does not appear. and if there are unsaved themes or labels. All rights reserved. when an application issues an End MapInfo statement. MapInfo Professional prompts the user to save or discard the table edits. if the user's system is set up so that it automatically saves MAPINFOW. Accordingly. If an application issues an End MapInfo statement. An application can define a special procedure called EndHandler. To halt a MapBasic application without exiting MapInfo Professional. See EndHandler procedure on page 267 for more information. this prompt does not appear.WOR on exit. Syntax End MapInfo [ Interactive ] Description The End MapInfo statement halts MapInfo Professional.

MapInfo Professional automatically removes any menu items created by that application. Note: Multiple MapBasic applications can be “sleeping” at the same time. MapBasic automatically calls that procedure when the application halts. See Also End MapInfo statement. for whatever reason the application halts. A MapBasic application can add items to MapInfo Professional menus. and even add entirely new menus to the menu bar. If the user runs an application containing a sub procedure named EndHandler. When an application halts. WinChangedHandler procedure. Typically. EndHandler procedure EndHandler procedure Purpose A reserved procedure name. that entire application is halted—even if “sleeping” procedures have been attached to custom menu items. SelChangedHandler procedure. Once a MapBasic application has connected a procedure to the menu in this fashion. WinClosedHandler procedure Reference Guide © 2006 MapInfo Corporation. ToolHandler procedure. called automatically when an application terminates. the application is said to be “sleeping. the EndHandler procedure is called automatically when the application ends. See Also RemoteMsgHandler procedure. All rights reserved.EndHandler procedure Description The End Program statement halts execution of a MapBasic program. one after another. This happens whether the user exited MapInfo Professional or another procedure in the application issued an End Program statement.” If any procedure in a MapBasic application issues an End Program statement. a menu item added in this fashion calls a sub procedure from a MapBasic program. When MapInfo Professional terminates. Syntax Declare Sub EndHandler Sub EndHandler statement_list End Sub statement_list is a list of statements to execute when the application terminates. 267 . If an application defines a procedure named EndHandler. Description EndHandler is a special-purpose MapBasic procedure name. MapBasic automatically calls all sleeping EndHandler procedures.

The EOF( ) function works with open files. Return Value Logical Description The EOF( ) function returns a logical value indicating whether the End-Of-File condition exists for the specified file. Return Value Logical 268 © 2006 MapInfo Corporation. FALSE otherwise. see the sample program NVIEWS. otherwise. All rights reserved. If a Get statement tries to read past the end of the specified file. EOF( ) returns a value of FALSE. the EOF( ) function returns a value of TRUE.5 . Open File statement EOT( ) function Purpose Returns TRUE if MapBasic has reached the end of the specified table. The integer filenum parameter represents the number of an open file. Error Conditions ERR_FILEMGR_NOTOPEN error generated if the specified file is not open.MB (Named Views). Syntax EOF( filenum ) filenum is the number of a file opened through the Open File statement.EOF( ) function EOF( ) function Purpose Returns TRUE if MapBasic tried to read past the end of a file. MapBasic 8. use the EOT( ) function. Syntax EOT( table ) table is the name of an open table. See Also EOT( ) function. when you wish to check the current position of an open table. For an example of calling EOF( ). FALSE otherwise.

Fetch statement. SRS strings are also referred to as EPSG (European Petroleum Survey Group) strings (for example. All rights reserved. Open Table statement EPSGToCoordSysString$( ) function Purpose Converts a string containing a Spatial Reference System into a CoordSys clause that can be used with any MapBasic function or statement. Syntax EPSGToCoordSysString$( epsg_string ) epsg_string is a String describing a Spatial Reference System (SRS) for any supported coordinate systems. Reference Guide © 2006 MapInfo Corporation.PRJ file in your MapInfo Professional installation. epsg:2600).EPSGToCoordSysString$( ) function Description The EOT( ) function returns TRUE or FALSE to indicate whether MapInfo Professional has tried to read past the end of the specified table. For a complete list of EPSG codes used with MapInfo Professional see the MAPINFOW. The EPSG codes are identified by a “\p” followed by a number. until the point when the EOT( ) function indicates that the program has reached the end of the table. Description The EPSGToCoordSysString$( ) is used to convert a SRS String into a CoordSys clause that can be used in any MapBasic function or statement that takes a CoordSys clause as an input. Dim f_total As Float Open Table "customer" Fetch First From customer Do While Not EOT(customer) f_total = f_total + customer. Error Conditions ERR_TABLE_NOT_FOUND error generated if the specified table is not available Example The following example uses the logical result of the EOT( ) function to decide when to terminate a loop. The loop repeatedly fetches the next record in a table. Open File statement. The table parameter represents the name of an open table. 269 .order Fetch Next From customer Loop See Also EOF( ) function.

o2 ) End If Else Note "Cannot Erase." End If 270 © 2006 MapInfo Corporation. run command("Set Map " + EPSGToCoordSysString$("EPSG:4326")) See Also CoordSys clause Erase( ) function Purpose Returns an object created by erasing part of another object. and returns an object expression representing what remains of the object. eraser_object ) source_object is an object. The object returned retains the color and pattern styles of the source_object.Erase( ) function Example The following example sets the coordinate system of a map to Earth Projection 1. but cannot be a point object or text object. 104. polyline. All rights reserved.5 . eraser_object is a closed object. or arc) or a closed object (region. rounded rectangle. o1 and o2 are Object variables ' that already contain Object expressions. The source_object parameter can be a linear object (line. nothing would remain. The eraser_ object must be a closed object. rectangle. cannot be a point or text object. part of which is to be erased. or ellipse). Syntax Erase( source_object." Else o3 = Erase( o1. Return Value Returns an object representing what remains of source_object after erasing eraser_object. If o1 Intersects o2 Then If o1 Entirely Within o2 Then Note "Cannot Erase. representing the area that will be erased. MapBasic 8. Description The Erase( ) function erases part of an object. Example ' In this example. objects do not intersect.

not all error codes are identified in the Error Conditions heading. However. specific circumstances. it returns zero. many functions. by issuing an OnError statement. other MapBasic errors are “generic”. when the current row from that table has no associated object. take an Object expression as a parameter. representing the current error. listing error codes related to that statement or function. the ERR_INVALID_CHANNEL error is only generated by DDE-related functions or statements. a program can set up an error handling routine to respond to error conditions. Reference Guide © 2006 MapInfo Corporation. Any such function will generate the ERR_ FCN_OBJ_FETCH_FAILED error if you pass an expression of the form tablename.obj as a parameter. Once the program issues a Resume statement to return from the error handling routine. Once an error handling routine is specified. for example. In other words. For example. Some statement and function descriptions within this document contain an Error Conditions heading (just before the Example heading). MapBasic jumps to that routine automatically in the event of an error. and might be generated under a variety of broadlydefined circumstances. 271 . the discussion for that statement will identify the error under the Error Conditions heading. such as Area( ) function and ObjectInfo( ) function. any function which takes an Object parameter might generate the ERR_FCN_OBJ_FETCH_FAILED error. By default. However. the error condition is reset. However. Some MapBasic error codes are only generated under narrowly-defined. a MapBasic program which generates an error will display an error message and then halt. The error handling routine can then call the Err( ) function to determine which error occurred.Err( ) function See Also Objects Erase statement. Since the ERR_FCN_OBJ_FETCH_FAILED error can occur in so many different places. Syntax Err( ) Return Value Integer Description The Err( ) function returns the numeric code indicating which error occurred most recently. The Err( ) function can only return error codes while within the error handler. All rights reserved. This means that if you call the Err( ) function outside of the error handling routine. If a statement might generate such an “unusual” error. individual functions do not explicitly identify the error. Objects Intersect statement Err( ) function Purpose Returns a numeric code.

See Also Err( ) function. Cos( ) function. Syntax Error$( ) Return Value String 272 © 2006 MapInfo Corporation. Atn( ) function. If no error handling routine has been enabled. Log( ) function. The complete list of potential MapBasic error codes is included in the file ERRORS. or Tan( ) function. Error$( ) function. If an error-handling routine has been enabled through an OnError statement. All rights reserved. MapBasic 8. the simulated error will cause MapBasic to perform the appropriate error-handling routine.DOC. Description The Error statement simulates the occurrence of an error. Syntax Error error_num error_num is an integer error number. Sin( ) function. OnError statement Error$( ) function Purpose Returns a message describing the current error. OnError statement Error statement Purpose Simulates the occurrence of an error condition. Error$( ) function. there are two math errors—ERR_FP_MATH_LIB_DOMAIN and ERR_FP_MATH_LIB_ RANGE—which can occur as a result of an invalid numeric parameter. See Also Error statement.Error statement Similarly.5 . Asin( ) function. Sqr( ) function. Exp( ) function. the error simulated by the Error statement will cause the MapBasic application to halt after displaying an appropriate error message. These errors might be generated by calls to any of the following functions: Acos( ) function.

a Do…Loop statement can appear within the body of another. Exit For statement. Do…Loop statements can be nested. MapBasic will jump to the first statement following the Do…Loop statement. See Err( ) function on page 271 for more information. All rights reserved. if an error has occurred. that is. Note that the Exit Do statement is only valid within a Do…Loop statement. See Also Err( ) function. If no error has occurred. Thus. The Error$( ) function should only be called from within an error handling routine. Restrictions You cannot issue an Exit Do statement through the MapBasic window.Exit Do statement Description The Error$( ) function returns a character string describing the current run-time error. OnError statement Exit Do statement Purpose Exits a Do…Loop statement prematurely. See Also Do…Loop statement. the Error$( ) function returns a null string. An Exit Do statement only halts the iteration of the nearest Do…Loop statement. Exit Sub statement Reference Guide © 2006 MapInfo Corporation. “outer” Do…Loop statement. Error statement. Syntax Exit Do Description An Exit Do statement terminates a Do…Loop statement. Upon encountering an Exit Do statement. in an arrangement of this sort: Do While condition1 : Do While condition2 : If error_condition Exit Do End If : Loop : Loop the Exit Do statement will halt the inner loop (Do While condition2) without necessarily affecting the outer loop (Do While condition1). 273 .

For…Next statements can be nested. that is.5 . All rights reserved. Upon encountering an Exit For statement.Exit For statement Exit For statement Purpose Exits a For…Next statement prematurely. Note that an Exit For statement only halts the iteration of the nearest For…Next statement. See Also Exit Do statement. MapBasic 8. Restrictions You cannot issue an Exit Function statement through the MapBasic window. 274 © 2006 MapInfo Corporation. MapBasic will jump to the first statement following the For…Next statement. in an arrangement of this sort: For x = 1 to 5 : For y = 2 to 10 step 2 : If error_condition Exit For End If : Next : Next the Exit For statement will halt the inner loop (For y = 2 to 10 step 2) without necessarily affecting the outer loop (For x = 1 to 5). Syntax Exit For Description An Exit For statement terminates a For…Next statement. Thus. Note that the Exit For statement is only valid within a For…Next statement. “outer” For…Next statement. a For…Next statement can appear within the body of another. Restrictions You cannot issue an Exit For statement through the MapBasic window. For…Next statement Exit Function statement Purpose Exits a Function… End Function statement.

Exit Sub statement Syntax Exit Function Description An Exit Function statement causes MapBasic to exit the current function. Restrictions You cannot issue an Exit Sub statement through the MapBasic window. Accordingly. which. in turn. Sub…End Sub statement may be nested. one function can call another function. which. Syntax Exit Sub Description An Exit Sub statement causes MapBasic to exit the current sub procedure. an Exit Function statement may only be issued from within a Function… End Function statement. an Exit Sub statement may only be issued from within a sub procedure. in other words. Accordingly. Function calls may be nested. Note that a single Exit Sub statement exits only the current sub procedure. See Also Call statement. can call yet another function. Sub…End Sub statement Exp( ) function Purpose Returns the number e raised to a specified exponent. See Also Function… End Function statement Exit Sub statement Purpose Exits a Sub…End Sub statement. Note that a single Exit Function statement exits only the current function. can call yet another sub procedure. Syntax Exp( num_expr ) Reference Guide © 2006 MapInfo Corporation. in turn. 275 . etc. in other words. All rights reserved. one sub procedure can call another sub procedure.

7182818. or ASCII text files) Export table Into file_name [ Type { "MIF" | "DBF" Charset char_set ] | "ASCII" Charset char_set ] [ Delimiter "d " ] [ Titles ] } ] "CSV" [ Charset char_set ] [ Titles ] } ] [ Overwrite ] Syntax 2 (for exporting DXF files) Export table Into file_name [ Type "DXF" ] [ Overwrite ] [ Preserve [ AttributeData ] [ Preserve ] [ MultiPolygonRgns [ As Blocks ] ] ] [ { Binary | ASCII [ DecimalPlaces decimal_places ] } ] [ Version { 12 | 13 } ] [ Transform 276 © 2006 MapInfo Corporation. DBF files.7182818 See Also Cos( ) function. MapBasic 8. Example Dim e As Float e = Exp(1) ' the local variable e now contains ' approximately 2. Sin( ) function. Note: MapBasic supports general exponentiation through the caret operator (^). All rights reserved.Export statement num_expr is a numeric expression. Log( ) function Export statement Purpose Exports a table to another file format. Return Value Float Description The Exp( ) function raises the mathematical value e to the power represented by num_expr.5 . e has a value of approximately 2. Syntax 1 (for exporting MIF/MID files.

then use a CAD software package to import the DXF file. DXF_x1. 277 . such as “WindowsLatin1”. DXF_y2 ) ] table is the name of an open table. The Export statement does not alter the original table. Reference Guide © 2006 MapInfo Corporation. MI_y1. you could export the contents of a table to a DXF file. etc. the export file is created in the current working directory. Description The Export statement copies the contents of a MapInfo table to a separate file.DXF” MapInfo Professional creates a DXF file. I Type clause Type “MIF” File Format Specified MapInfo Interchange File format. such as AutoCAD). are numbers that represent bounds coordinates in the DXF file. DXF_y1 ) ( DXF_x2. are numbers that represent bounds coordinates in the MapInfo Professional table. see CharSet clause on page 125 for details.Export statement ( MI_x1. MI_y1 ) ( MI_x2. Type “DXF” Type “DBF” Type “ASCII” Text file format. d is a character used as a delimiter when exporting an ASCII file. decimal_places is a small integer (from 0 to 16. Note: Map objects are not exported when you specify DBF format. etc. For example. All rights reserved. which controls the number of decimal places used when exporting floating-point numbers in ASCII. do not use quotation marks around this name. using a file format which other packages could then edit or import. For information on the MIF file format. If you omit the Type clause. Type “CSV” Comma-delimited text file format. Note: Map objects are not exported when you specify CSV format. char_set is a string that identifies a character set. file_name is a string specifying the file name to contain the exported data. DXF_y1. if you specify the file name “PARCELS. if the file name does not include a path. Specifying the File Format The optional Type clause specifies the format of the file you want to create. see the MapInfo Professional documentation. dBASE file format. MI_y2 ) ( DXF_x1. MapInfo Professional assumes that the file extension indicates the desired file format. default value is 6). For example. MI_x1. Note: Map objects are not exported when you specify ASCII format. DXF file (a format supported by CAD packages.

The Version 12 or Version 13 clause controls whether MapInfo Professional creates a DXF file compliant with AutoCAD 12 or 13. If you do not include either keyword. the Export statement can include the following DXF-specific clauses: Include the Preserve AttributeData clause if you want to export the table's tabular data as attribute data in the DXF file. include the optional Delimiter clause. each polygon from a multiple-polygon region is stored separately.) as the delimiter. you may want to include the optional Titles keyword. the text file will contain delimiters. Binary DXF files are generally smaller. the first row of the text file will contain the table's column names.txt" Type "ASCII" Delimiter ":" Titles When you export to an ASCII or CSV text file. Include the Preserve MultiPolygonRgns As Blocks clause if you want MapInfo Professional to export each multiple-polygon region as a DXF block entity. If you omit this clause. MapInfo Professional creates a version 12 DXF file. A delimiter is a special character that separates the fields within each row of data. CSV text files automatically use a comma (. Exporting DXF Files If you export a table into DXF file. 6 is the default). To specify a different delimiter. 278 © 2006 MapInfo Corporation. include the ASCII keyword to export into an ASCII text DXF file.5 . When you export as ASCII. MapInfo Professional does not overwrite the file. If you omit the Overwrite keyword. If you include Titles. and then specify the minimum and maximum coordinates that you want to have in the DXF file.and y-bounds coordinates of the MapInfo table. MapBasic 8. the column names will not be stored in the text file (which could be a problem if you intend to re-import the file later). If you omit the clause. No other delimiter can be specified for CSV export. you specify the minimum and maximum x. or. and the file already exists. If you omit Titles. MapInfo Professional creates the export file.Export statement If you include the optional Overwrite keyword. All rights reserved. MapInfo Professional creates an ASCII DXF file. Include the Binary keyword to export into a binary DXF file. you can specify the number of decimal places used to store floating-point numbers (0 to 16 decimal places. The following example uses a colon (:) as the delimiter: Export sites Into "sitedata. Transform specifies a coordinate transformation. Exporting ASCII Text Files When you export a table to an ASCII or CSV text file. regardless of whether a file by that name already exists. using Syntax 2 as shown above. and can be processed much faster than ASCII. The default delimiter for an ASCII text file is the TAB character (Chr$(9)). In the Transform clause.

) of the original object. polygon_index. b_region ) object is a polyline or region object.DXF”. Facility. end_node is a SmallInt node number. This indicates which polygon (for regions) or section (for polylines) to query. Open Table "facility" Export facility Into "FACIL. MapBasic applies the current drawing styles. begin_node. 1) See Also Import statement ExtractNodes( ) function Purpose Returns a polyline or region created from a subset of the nodes in an existing object. 1 or larger: for region objects. begin_node is a SmallInt node number. 1 or larger.DXF" Type "DXF" Overwrite Preserve AttributeData Preserve MultiPolygonRgns As Blocks ASCII DecimalPlaces 3 Transform (0. and exports the table to a DXF file called “FACIL. Reference Guide © 2006 MapInfo Corporation. MapBasic applies all styles (color. use TRUE for a region object or FALSE for a polyline object. 0) (1. polygon_index is an integer value. Syntax ExtractNodes( object. etc. 279 . 0) (1. b_region is a logical value that controls whether a region or polyline object is returned. indicates the end of the range of nodes to return.ExtractNodes( ) function Example The following example takes an existing MapInfo table. Return Value Returns an object with the specified nodes. then. 1) (0. if necessary. All rights reserved. indicates the beginning of the range of nodes to return. 1 or larger. end_node.

This provides a simple mechanism for extracting a single polygon from a multiple-polygon region. If All is used. then a distance object is created for every combination. MapBasic returns the entire set of nodes for that polygon. If object is a region object. ObjectNodeY( ) function Farthest statement Purpose Find the object in a table that is farthest from a particular object. Syntax Farthest [ N | All ] From { Table fromtable | Variable fromvar } To totable Into intotable [ Type { Spherical | Cartesian }] [ Ignore [ Contains ][ Min min_value ][ Max max_value ] Units unitname] [ Data clause ] N is an optional parameter for the number of “farthest” objects to find. fromtable is a table of objects from which you want to find farthest distances. All rights reserved. or if b_region is TRUE and the range of nodes contains fewer than three nodes. max_value is the maximum distance to include in the results. See Also ObjectNodeX( ) function. MapBasic 8. intotable is a table to place the results into. First node in polygon through end_node. To determine the number of polygons in a region. call the ObjectInfo( ) function. min_value is the minimum distance to include in the results. The result is a two-point Polyline object representing the farthest distance. Error Conditions ERR_FCN_ARG_RANGE error generated if b_region is FALSE and the range of nodes contains fewer than two nodes. The default is 1.Farthest statement Description If the begin_node is equal to or greater than end_node. fromvar is a MapBasic variable representing an object that you want to find the farthest distances from. totable is a table of objects that you want to find farthest distances to.5 . and if begin_node and end_node are both equal to 1. 280 © 2006 MapInfo Corporation. the nodes are returned in the following order: • • begin_node through the next-to-last node in the polygon.

The types of the objects in the fromtable and totable can be anything except Text objects. and the results should not contain duplicates (i.e. A two-point Polyline object representing the farthest points between the fromtable object and the chosen totable object is placed in the intotable. For example. and the two-point Polyline returned will be degenerate. The Max distance can be used to limit the objects to consider in the totable. then the minimum distance is zero. and three objects are requested. It is strictly a “as the bird flies” distance. since it effectively limits the number of totable objects that are searched. “km”) used for min_value and/or max_value. we may want to exclude cases of the same city. then only one of them may be returned. then an object is placed in the intotable representing the distance between the fromtable object and each totable object. where we would find all airports within 100 miles of a city. If multiple objects are requested (i. and can effect how many totable objects are found for each fromtable object. The Ignore clause can be used to limit the distances to be searched. we may want to search for the five airports that are closest to a set of cities (where the fromtable is the set of cities and the totable is a set of airports).Farthest statement unitname is string representing the name of a distance unit (for example. If there are multiple objects in the totable that are the same distance from a given fromtable object. Reference Guide © 2006 MapInfo Corporation. This may be useful in the case of two point tables to eliminate comparisons of the same point. the first pass may return all objects between 0 and 100 miles. but we don't care about airports that are farther away than 100 miles. then the N farthest objects in the totable are found. Every object in the fromtable is considered. If a tie exists at the second farthest object. For example. This may be most useful in conjunction with N or All. This may result in less than five airports being returned for a given city. If the Region objects intersect. and the second pass may return all objects between 100 and 200 miles. If All is specified. All rights reserved. if N is greater than 1). The effective distances found are strictly greater than the min_value and less than or equal to the max_value: min_value < distance <= max_value This can allow ranges or distances to be returned in multiple passes using the Farthest statement. then objects of the same distance will fill subsequent slots. and the two-point Polyline object produced represents the points on each object used to calculate that distance. If N is defined.. and we want to find the closest cities. Supplying a Max parameter can improve the performance of the Farthest statement. then one of the second farthest objects will become the third farthest object. if both tables contain Region objects. For example. where both points are identical and represent a point of intersection. the furthest object in the totable is found. if there are two point tables representing Cities. This could also be used in conjunction with the All parameter. a distance of 100 should only occur in the first pass and never in the second pass)..e. then the minimum distance between Region objects is found. 281 . For example. For each object in the fromtable. Description The Farthest statement finds all the objects in the fromtable that is furthest from a particular object. One use of the Min distance could be to eliminate distances of zero. The distances calculated do not take into account any road route distance.

If unitname is not a valid distance unit.state_name To fill a column in the intotable with the distance. and the distance method is Cartesian. then the column in totable will be used (e. as are the Min and Max sub clauses within it. If the Coordsys of the intotable is Latitude/Longitude. Normally. CartesianConnectObjects( ) function. then an error will occur. For example. an error will occur. this will treat all closed objects. MapBasic 8. If the Contains keyword is used within the Ignore clause. if fromtable is WorldCaps and totable is World. If the Coordsys of the intotable is NonEarth and the distance method is Spherical. To avoid any conflicts such as this. then an error will occur. Data Clause Data IntoColumn1=column1. For example: Data name1=states. In effect. min_value and max_value are in the distance unit signified by unitname. ConnectObjects( ) function. Instead. Any distances found which are less than or equal to min_value or greater than max_value are ignored.g. The entire Ignore clause is optional. such as regions. If the same column name exists in both totable and fromtable. CartesianObjectDistance( ) function. The Ignore clause limits the distances returned. All rights reserved. The Data clause can be used to mark which fromtable object and which totable object the result came from.Farthest statement Type is the method used to calculate the distances between objects.5 . then the distance will not be automatically be zero. name2=county. we can either use the Table > Update Column functionality from the menu or use the Update statement. SphericalConnectObjects( ) function 282 © 2006 MapInfo Corporation.state_name. IntoColumn2=column2 The IntoColumn on the left hand side of the equals sign must be a valid column in intotable. the column names can be qualified using the table alias. the distance from London to the boundary of the United Kingdom will be returned. See Set Distance Units statement on page 570 for the list of available unit names. if one object is contained within another object. The type of distance calculation must be correct for the coordinate system of the intotable or an error will occur. the distance between the objects is zero. See Also Nearest statement. It can either be Spherical or Cartesian. as polylines for the purpose of this operation.. totable is searched first for column names on the right hand side of the equals sign). The column name on the right hand side of the equals sign must be a valid column name from either totable or fromtable. then the distance between London and the United Kingdom would be zero. SphericalObjectDistance( ) function. ObjectDistance( ) function.

Description Use the Fetch statement to retrieve records from an open table.e. Accordingly. Fetch statements should be issued just before any statements that make assumptions about which row is current. Note: If the specified record is deleted. which row is the current row). you can retrieve data from the current row by using one of the following expression types: Syntax table. your program places the table cursor at a certain row position in the table.col( 1 ) Example A Fetch First statement positions the cursor at the first un-deleted row in the table. table is the name of an open table. A Fetch Last statement positions the cursor at the last un-deleted row in the table.Fetch statement Fetch statement Purpose Sets a table's cursor position (i.. This has nothing to do with the on-screen mouse cursor. Syntax Fetch { First | Last | Next | Prev | Rec n } From table n is the number of the record to read. even if that row is deleted. and screen redraws) automatically reset the current row. Note: The term “cursor” is used here to signify a row's position in a table. By issuing a Fetch statement.col1 World.column table. A Fetch Prev statement moves the cursor backward to the previous un-deleted row. Reference Guide © 2006 MapInfo Corporation. A Fetch Next statement moves the cursor forward to the next un-deleted row.col# table. this dictates which of the records in the table is the “current” record. 283 . After you issue a Fetch statement. Various MapInfo Professional and MapBasic operations (for example. Select. Update. A Fetch Rec n statement positions the cursor on a specific row. All rights reserved.Country World. the statement generates run-time error 404.col( number ) World.

col1 + " has negative net migration" See Also EOT( ) function. there is an end-of-table condition. Open Table statement 284 © 2006 MapInfo Corporation. you may need to call the EOT( ) function to determine whether you fetched an actual row. there is not an end-of-table condition). the Fetch statement can operate on a temporary table (for example.state_name 'display name of state As illustrated in the example below. causing the loop to halt. If the Fetch statement placed the cursor on an actual row. the EOT( ) function returns TRUE (meaning. All rights reserved. Dim i As Integer i = 0 Fetch First From world Do While Not EOT(world) i = i + 1 Fetch Next From world Loop Print "Number of undeleted records: " + i Examples The following example shows how to fetch the 3rd record from the table States: Open Table "states" Fetch Rec 3 From states 'position at 3rd record Note states. therefore there is no “current row”). MapBasic 8. If the Fetch statement attempted to place the cursor past the last row. As soon as a Fetch Next statement attempts to read past the final row. the EOT( ) function returns FALSE (meaning. Selection). the EOT( ) function returns TRUE.5 . The following example shows how to use a Fetch Next statement to loop through all rows in a table.Fetch statement Reading Past the End of the Table After you issue a Fetch statement. Select * From states Where pop_1990 < pop_1980 Fetch First From Selection Note Selection.

attribute is a code indicating which file attribute to return. Return Value Integer Description The FileAttr( ) function returns information about an open file.FileAttr( ) function FileAttr( ) function Purpose Returns information about an open file. indicating the mode in which the file was opened. Error Conditions The ERR_FILEMGR_NOTOPEN error is generated if the specified file is not open. indicating the file size in bytes. attribute ) filenum is the number of a file opened through an Open File statement. Open File statement. Return value will be one of the following: • • • • • MODE_INPUT MODE_OUTPUT MODE_APPEND MODE_RANDOM MODE_BINARY FILE_ATTR_FILESIZE Integer. 285 . Get statement. Syntax FileAttr( filenum. Put statement Reference Guide © 2006 MapInfo Corporation. See Also EOF( ) function. see table below. All rights reserved. The attribute parameter must be one of the codes in this table: attribute parameter FILE_ATTR_MODE Return Value Small integer.

Example If FileExists("C:\MapInfo\TODO. indicating the default file name for the user to choose. Return Value Logical: TRUE if the file already exists. otherwise FALSE. All rights reserved. Syntax FileOpenDlg( path. indicating a file type (for example. prompt is a string title that appears on the bar at the top of the dialog box. filetype. filename is a string value. three or four characters long. “TAB” to specify tables). indicating the directory or folder to choose files from. filetype is a string value. Syntax FileExists( filespec ) filespec is a string that specifies the file path and name. representing the name of the file the user chose (or an empty string if the user cancelled).5 . MapBasic 8. 286 © 2006 MapInfo Corporation. and returns the name of the file the user selected.FileExists( ) function FileExists( ) function Purpose Returns a logical value indicating whether or not a file exists. filename.TXT") Then Open File "C:\MapInfo\TODO. prompt ) path is a string value. Return Value String value.TXT" For INPUT As #1 End If See Also TempFileName$( ) function FileOpenDlg( ) function Purpose Displays a File Open dialog box.

dBASE or compatible data files Lotus spreadsheet files Excel spreadsheet files AutoCAD data interchange format files MapInfo for DOS interchange files “DBF” “WKS”. for example.*”). Alternately. the dialog returns a null string (""). it merely presents the user with a dialog box. usually three or four characters long. “WK1” “XLS” “DXF” “MMI”. the FileOpenDlg( ) function returns a character string representing the full path and name of the file the user chose. If you want your application to display an Open dialog box. the dialog box presents a list of MapInfo workspace files. the user can either click a file in the list and click the OK button. the dialog box presents a list of MapInfo tables. The FileOpenDlg( ) function does not actually open any files. summarized in the table below. There are also a variety of other three-character filetype values. the dialog box presents a list of files in the current working directory. In either case. if the filetype parameter is “TAB”. and if the filetype parameter is “WOR”. All rights reserved. Some filetype settings have special meaning. “MBI” Reference Guide © 2006 MapInfo Corporation. if the user clicks the Cancel button instead of picking a file. which indicates the type of files that should appear in the dialog box. you can issue a statement such as the Run Menu Command statement with M_FILE_OPEN or M_FILE_ADD_WORKSPACE. If your application then needs to actually open the file chosen by the user. and lets the user choose a file. the application must issue a statement such as the Open Table statement. filetype parameter “TAB” “WOR” “MIF” MapInfo tables MapInfo workspaces Type of files that appear MapInfo Interchange Format files. the dialog box includes a control that lets the user choose between seeing a list of table files or a list of all files (“*. or simply double-click a file in the list. To choose a file from the list that appears in the dialog box. The filename parameter specifies the default file name for the user to choose. 287 . it does not prevent the user from changing directories once the dialog box appears. and then you want MapInfo Professional to automatically open the selected file. used for importing / exporting maps from / to ASCII text files.FileOpenDlg( ) function Description The FileOpenDlg( ) function displays a dialog box similar to the one that displays when the user chooses File > Open. Note that the path parameter only dictates the initial directory. The path parameter specifies the directory or folder from which the user will choose an existing file. The filetype parameter is a string. If you specify one of the special type values from the table below. If the path parameter is blank (a null string).

filename is a string value. 288 © 2006 MapInfo Corporation. To help you write portable applications. Open Table statement FileSaveAsDlg( ) function Purpose Displays a Save As dialog box. and returns the name of the file the user entered.TAB extension. filename. a control in the lower left corner of the dialog box lets the user choose whether to see a list of files with the . MapBasic 8. filetype is a string value. indicating the type of file that the dialog box lets the user choose. or a list of all files in the current directory. MapBasic lets you use the same three-character filetype settings on all platforms. specifying a filetype parameter of “WOR” tells MapBasic to display a list of files having the “. because that is the extension used by MapInfo Professional workspaces. All rights reserved. Syntax FileSaveAsDlg( path."TAB". representing the name of the file the user entered (or an empty string if the user cancelled)."Open Table") See Also FileSaveAsDlg( ) function. in other words. Open File statement. Return Value String value. On Windows.5 .FileSaveAsDlg( ) function filetype parameter “MB” “MBX” “TXT” “BMP” “WMF” Type of files that appear MapBasic source program files Compiled MapBasic applications Text files Windows bitmap files Windows metafiles Each of the three-character file types listed above corresponds to an actual file extension."". indicating the default file name. Example Dim s_filename As String s_filename = FileOpenDlg("". If the FileOpenDlg( ) function specifies a filetype parameter which is not listed in the table of file extensions above. prompt is a string title that appears at the top of the dialog box. filetype.WOR” file extension. prompt ) path is a string value. indicating the default destination directory. the dialog box appears without that control.

The filetype parameter is a three-character (or shorter) string which identifies the type of files that should appear in the dialog box. The user can change directories once the dialog box appears. it merely presents the user with a dialog box. region ] [ Interactive ] address is a string expression representing the name of a map object to find. similar to the dialog box that displays when the user chooses File > Save Copy As. Since each file name in the list represents an existing file. If the path parameter is blank (a null string). See Also Commit Table statement. to display a dialog box that lists table names. The path parameter specifies the initial directory path. MapBasic asks the user to verify that they want to overwrite the existing file. To display a dialog box that lists workspaces. Alternately. and lets the user choose a file name to save. region is the name of a region object which refines the search. the FileSaveAsDlg( ) function returns a character string representing the full path and name of the file the user chose. The filename parameter specifies the default file name for the user to choose. To save data under the file name chosen by the user. 289 . If the user clicks the Cancel button instead of picking a file. Reference Guide © 2006 MapInfo Corporation. use the syntax: streetname && streetname. issue a statement such as the Commit Table statement. specify the string “WOR” as the filetype parameter.Find statement Description The FileSaveAsDlg( ) function displays a Save As dialog box. All rights reserved. to find the intersection of two streets. The FileSaveAsDlg( ) function does not actually save any files.” See FileOpenDlg( ) function on page 286 for more information about three-character filetype codes. specify the string “TAB. The user can type in the name of the file they want to save. Syntax Find address [ . the dialog box presents a list of files in the current directory. FileOpenDlg( ) function Find statement Purpose Finds a location in a mappable table. the user can double-click from the list of grayed-out filenames that appears in the dialog box. If the user specifies a filename and clicks OK. the function returns a null string ("").

290 © 2006 MapInfo Corporation. The table must already be open. MapBasic searches whichever table was specified the last time the user chose MapInfo Professional's Query > Find command. you could simply try to find a city name (for example. “Albany”. a table which has graphic objects attached). call CommandInfo(CMD_INFO_X) to determine the x-coordinate of the queried location. To determine the row number that corresponds to the “found” address. an approximate match. call CommandInfo(CMD_INFO_FIND_ROWID). The return value has up to three digits.) xx5 ( + ) Exact match. the function call returns a negative value. “CA”). A MapBasic program can issue a Find Using statement to identify a specific table column to search. which a program can then access through the CommandInfo( ) function. All rights reserved. Determining Whether the Address Was Found Following a Find statement. see example below. Meaning A substitution from the abbreviations file used. match not found. call the CreatePoint( ) function or the Create Point statement. and that each of the three digits indicates the relative success or failure of a different part of the search. The Find statement does not automatically add a symbol to the map to mark where the address was found. The Find statement may result in an exact match. The table below summarizes the Find-related information represented by the CommandInfo(CMD_ INFO_FIND_RC) return value. “Albany”) by searching a table of cities. To create such a symbol. a dialog box displays a list of “near matches.) xx4 ( . The Find statement operates on whichever column is currently chosen for searching. In other words. If the Find statement includes the optional Interactive keyword. If the Find statement is not preceded by a Find Using statement. If the Find statement results in an approximate match.Find statement Description The Find statement searches a mappable table for a named location (represented by the address parameter). No object name specified. Digit Values xx1 xx2 xx3 ( . If the Find statement results in an exact match. The user chose a name from the Interactive dialog box. and if MapBasic is unable to locate the specified address. or you could refine the search by specifying both a city name and a region name (for example. a MapBasic program can issue the function call CommandInfo(CMD_ INFO_FIND_RC) to determine if the search was successful. the function call returns a value greater than one (1). the function call CommandInfo(CMD_INFO_FIND_RC) returns a value of one (1). Exact match not found. MapBasic stores the search results in system variables. The Find statement can optionally refine a search by specifying a region name in addition to the address parameter. or a failure to match. If the Find statement fails to match the address. and call CommandInfo(CMD_INFO_Y) to determine the y-coordinate.” The Find statement can only search a mappable table (for example. If the search was successful. MapBasic 8.5 .

) 4xx ( . while the 3 digit indicates that MapBasic was only partly successful in locating a correct refining region. The 1 digit signifies that the city name matched exactly. in other words. If a MapBasic program then issues a Find statement with “Albany” as the address and a null string as the state name.) x5x ( . Name found in more than one region other than the specified region. If a table of cities contains one entry for “Albany”. Now suppose that the Find operation has been set up to refine the search with an optional region name. that is technically not an exact match.) 5xx ( + ) 6xx ( + ) Side of street undetermined. MapBasic will be able to locate that record. if there is only one “Albany” record in the table. use the expression number Mod 10. and the Find Using statement attempts to locate a city name without a refining region name. Strictly speaking. use the expression number Mod 100. and multiple matches were found. If a table of streets contains “Main St”. the search results in an exact match. For example. Streets do not intersect. No refining region was specified. etc. Meaning The Mod operator is useful when examining individual digits from the Find result. and one match was found. 291 . Name found more than once in the specified region. and a Find statement attempts to locate “Main Street”. Name found in only one region other than specified region. and the Find statement specifies an address parameter value of “Albany”. All rights reserved. The user chose an address number from the Interactive dialog box.) x3x ( + / .) x4x ( + / . see Find Using statement on page 292). the function call CommandInfo(CMD_INFO_FIND_RC) would return a value of 1 (one). the function call CommandInfo(CMD_INFO_FIND_RC) would return a value of 301. Following such a Find statement. To determine the last two digits of a number. “Albany”. the Reference Guide © 2006 MapInfo Corporation.) 2xx ( . The user chose a region name from the Interactive dialog box. Address number was not specified.) x7x ( + ) 1xx ( + / . MapBasic considers the result to be an approximate match (assuming that abbreviation file processing has been enabled. Address number was within min/max range. The distinction between exact and approximate matches is best illustrated by example.Find statement Digit Values x1x x2x ( + / .) 3xx ( + / . “NY”).) x6x ( . Address number was not within min/max range. The row matched does not have a map object. Nevertheless. No region was specified. Following such a Find operation. to determine the last digit of a number. indicating that an exact match was found. the Find statement expects a city name followed by a state name (for example. because MapBasic expects the city name to be followed by a state name.

Find Using statement string “Main Street” does not match the string “Main St”. All rights reserved. then the return code will have a 1 (one) in the millions place. ' Create the object in the Cosmetic layer.ABB). y) ) Else Note "Location not found. and the user enters text in the dialog box in order to complete the find. However MapBasic is able to match the two strings after substituting possible abbreviations from the MapInfo abbreviations file (MAPINFOW. the CommandInfo(CMD_INFO_FIND_RC) function call returns a value of 2. MapBasic 8.5 . If the Find operation presents the user with a dialog box. Example Include "mapbasic. win_id As Integer Open Table "states" Interactive Map From States win_id = FrontWindow( ) Find Using states(state) Find "NY" If CommandInfo(CMD_INFO_FIND_RC) >= 1 Then x = CommandInfo(CMD_INFO_X) y = CommandInfo(CMD_INFO_Y) Set Map Window win_id Center (x. Syntax Find Using table ( column ) [ Refine Using table ( column ) ] [ Options [ Abbrs { On | Off } ] [ ClosestAddr { On | Off } ] [ OtherBdy { On | Off } ] [ Symbol symbol_style ] ] 292 © 2006 MapInfo Corporation.def" Dim x. y As Float." End If See Also Find Using statement. CommandInfo( ) function Find Using statement Purpose Dictates which table(s) and column(s) should be searched in subsequent Find operations. WIN_INFO_TABLE) (Object) Values ( CreatePoint(x. y) ' Now create a symbol at the location we found. Insert Into WindowInfo( win_id. Following the Find statement.

specify the clause OtherBdy On. this option is disabled (Off). By default. subsequent Find statements expect a location name and a region name (for example. If Distance Units are specified. The optional Abbrs clause dictates whether MapBasic will try substituting abbreviations from the abbreviations file in order to find a match. “mi” for miles. The Offset value sets the addresses back from the street instead of right on the street. By default. Description The Find Using statement specifies which table(s) and column(s) MapBasic will search when performing a Find statement. subsequent Find statements expect a simple location name (for example. column is the name of a column in the table. the last specified inset/offset options becomes the default settings for the next time. dist_unit is a string that represents the name of a distance unit (for example. The optional Refine clause specifies a second table. If you omit the Refine clause. value specifies the Offset value (the distance back from the street). inset_value represents the distance from the ends of the line where the address is to be placed. it represents the percentage of the length of the line where the address is to be placed. inset_value is a positive integer value representing how far from the ends of the line to adjust the placement of an address location.Find Using statement [ Inset inset_value { Percent | Distance Units dist_unit} ] [ Offset value ] [ Distance Units dist_unit ] ] table is the name of an open table. which will act as an additional search criterion. the table must contain region objects. “OR”). The optional ClosestAddr clause dictates whether MapBasic will use the closest available address number in cases where the address number does not match. “Portland”. value is a positive integer value representing how far to offset the placement of an address location back from the street. “Portland”). If Percent is specified. For distance. “m” for meters. Reference Guide © 2006 MapInfo Corporation. By default. to enable the option. specify the clause ClosestAddr On. Valid values are from 0 to 32. The optional OtherBdy clause dictates whether MapBasic will match to a record found in a refining region other than the refining region specified. Table > Geocode Options or executed a Find Using statement. Note that the column specified must be indexed. The specified column does not need to be indexed. specify the clause Abbrs Off. valid values for inset_value are from 0 to 50.767. All rights reserved. this option is enabled (On). The inset takes the addresses that would normally fall at the end of the street and moves them away from the end going in the direction towards the center. MapInfo Professional saves the Inset and Offset settings specified the last time the user chose Query > Find Options. Thus. this controls what type of symbol is drawn on the map if the user chooses Query > Find. 293 . to enable the option. symbol_style is a Symbol variable or a function call that returns a Symbol value.767. valid values for inset_value are from 0 to 32. this option is disabled (Off). For Percent. to disable the option. If you include a Refine clause.

Example Dim i_whole As Integer i_whole = Fix(5. Find statement Fix( ) function Purpose Returns an integer value. it returns the nearest integer value that is less than or equal to the original value. Syntax Fix( num_expr ) num_expr is a numeric expression. and returns the resultant integer value.Fix( ) function Example Find Using city_1k(city) Refine Using states(state) Find "Albany".5 .2) ' i_whole now has the value -7. i_whole = Fix(-7. 294 © 2006 MapInfo Corporation. When passed a negative fractional number. The Fix( ) function is similar to. Return Value Integer Description The Fix( ) function removes the fractional portion of a number.3) returns a value of -2.3) returns a value of -3. the Int( ) function. Thus. the function call: Int(-2. "NY" See Also Create Index statement.999) ' i_whole now has the value 5. Fix( ) returns the nearest integer value greater than or equal to the original value. the function call: Fix(-2. MapBasic 8. obtained by removing the fractional part of a decimal value. but not identical to. thus. All rights reserved. But when the Int( ) function is passed a negative fractional number. The two functions differ in the way that they treat negative fractional values.

This expression can be a Font variable: Font font_var or a call to a function (for example. Syntax Font font_expr font_expr is a Font expression. 295 . BLACK. CurrentFont( ) function or MakeFont( ) function) which returns a Font value: Font MakeFont("Helvetica". not a complete MapBasic statement. size. and background color) within parentheses: Font("Helvetica".Font clause See Also Int( ) function. the Set Legend statement). 12. and underline. this lets you choose the typeface and point size of the new text object. See table below for details. style. 1. style Reference Guide © 2006 MapInfo Corporation. for example. fgcolor. 12. allow you to specify a Font setting. such as the Create Text statement. WHITE) With some MapBasic statements (for example. Various object-related statements. the keyword Font can be followed immediately by the five parameters that define a Font style (font name. italic. Controls text attributes such as bold. Description The Font clause specifies a text style. point size. If you omit the Font expression from a Create Text statement. MakeFont( fontname. BLACK. foreground color. the new object uses MapInfo Professional's current Font. bgcolor ). WHITE) The following table summarizes the components that define a font: Component font name Description A string that identifies a font. style. The keyword Font may be followed by an expression that evaluates to a Font value. Integer value. 1. Round( ) function Font clause Purpose Specifies a text style. All rights reserved. The set of available fonts depends on the user's system and the hardware platform in use. Font is a clause.

12.9) Font MakeFont("Helvetica". omit the background color. specify 1 as the background color.BLACK. For example: Font( "Helvetica". to specify both the Bold and All Caps attributes. A point size of twelve is one-sixth of an inch tall.1.5 .DEF" Dim o_title As Object Create Text Into Variable o_title "Your message could go HERE" (73. The following table shows how the style parameter corresponds to font styles. 12. Integer RGB color value. foreground color background color Style Value 0 1 2 4 8 32 256 512 1024 Plain Bold Italic Underline Strikethrough Shadow Halo All Caps Expanded Description of text style To specify two or more style attributes.5. Example Include "MAPBASIC. BLACK).WHITE) 296 © 2006 MapInfo Corporation. otherwise. See Rnd( ) function on page 485. MapBasic 8.67. representing the color of the text. 42. 42. add the values from the left column. All rights reserved. To specify a transparent fill when calling the MakeFont( ) function. this is the background fill color. Integer RGB color value.6) (73. 1. this is the halo color.Font clause Component size Description Integer value representing a point size. To specify a transparent background style in a Font clause. If the halo style is used. For example. use a style value of 513.

The start_expr. and then adds the inc_expr increment value to the variable. Conversely. and inc_expr values dictate how many times. Restrictions You cannot issue a For…Next statement through the MapBasic window. MapBasic once again executes the statements in the statement_list. MapBasic then compares the current value of the variable to the end_expr expression. A For…Next statement either executes a group of statements (the statement_list) a number of times. statement_list is the group of statements to execute with each iteration of the For loop. MapBasic uses a default increment value of one. If. or else skips over the statement_list completely. Description The For…Next statement provides loop control. if the variable is currently less than or equal to the end_expr value. Chr$( ) function. 297 . If the variable is less than or equal to the end_expr value. Syntax For var_name = start_expr To end_expr [ Step inc_expr ] statement_list Next var_name is the name of a numeric variable. and MapBasic will only decide to continue executing the loop as long as var_name remains greater than or equal to the end_expr. If no Step clause was specified. the For…Next statement can also count downwards. MapBasic executes the group of statements in the statement_list. however. the var_name variable is greater than the end_expr. end_expr. All rights reserved. inc_expr is a numeric expression. RGB( ) function For…Next statement Purpose Defines a loop which will execute for a specific number of iterations. end_expr is a numeric expression. MapBasic assigns the start_expr value to the var_name variable. This statement requires a numeric variable (identified by the var_name parameter). Create Text statement. In this case. Reference Guide © 2006 MapInfo Corporation.For…Next statement See Also Alter Object statement. the statement_list will be carried out. Upon encountering a For…Next statement. if any. each iteration of the For loop decreases the value of the var_name variable. MapBasic stops the For loop. and resumes execution with the statement which follows the Next statement. start_expr is a numeric expression. by using a negative Step value.

However. Exit For statement 298 © 2006 MapInfo Corporation. MapBasic 8. Any statements which appear between the For and Next statements comprise the statement_list. The Exit For statement tells MapBasic to jump out of the loop. as a matter of programming style. you should try to avoid altering the contents of the var_name variable within the loop. Example Dim i As Integer ' the next loop will execute a Note statement 5 times For i = 1 to 5 Note "Hello world!" Next ' the next loop will execute the Note statement 3 times For i = 1 to 5 Step 2 Note "Hello world!" Next ' the next loop will execute the Note statement 3 times For i = 5 to 1 Step -2 Note "Hello world!" Next ' MapBasic will skip the following For statement ' completely.5 . The Exit For statement allows you to exit a For loop regardless of the status of the var_name variable. MapBasic permits you to modify the value of the var_name variable within the body of the For loop. because the initial start value is ' already larger than the initial end value For i = 100 to 50 Step 5 Note "This note will never be executed" Next See Also Do…Loop statement. and resume execution with the first statement which follows the Next statement. this can affect the number of times that the loop is executed. this is the list of statements which will be carried out upon each iteration of the loop.For…Next statement Each For statement must be terminated by a Next statement. All rights reserved.

. Syntax Declare Sub ForegroundTaskSwitchHandler Sub ForegroundTaskSwitchHandler statement_list End Sub statement_list is a list of statements. pattern ) Reference Guide © 2006 MapInfo Corporation. 299 . Syntax Format$( value... another app just became active End If End Sub See Also CommandInfo( ) function Format$( ) function Purpose Returns a string representing a custom-formatted number. All rights reserved. Description If the user runs an application containing a procedure named ForegroundTaskSwitchHandler.ForegroundTaskSwitchHandler procedure ForegroundTaskSwitchHandler procedure Purpose A reserved procedure name. Within the procedure. call the CommandInfo( ) function to determine whether MapInfo Professional received or lost the focus. Example Sub ForegroundTaskSwitchHandler If CommandInfo(CMD_INFO_TASK_SWITCH) = SWITCHING_INTO_MAPINFO Then ' .. called automatically when MapInfo Professional receives the focus (becoming the active application) or loses the focus (another application becomes active). MapInfo Professional calls the procedure automatically whenever MapInfo Professional receives or loses the focus. then MapInfo just became active Else ' .

the comma character (. If you wish to include a percent sign in your result. pattern character # Role in formatting results: The result will include one or more digits from the value. See examples below.” The result string will include the decimal separator currently in use on the user's computer. The pattern string should include one or more special format characters. Format$( ) can produce formatted results such as “$12. Return Value String Description The Format$( ) function returns a string representing a formatted number. the formatted result string will not include a zero before the decimal place.Format$( ) function value is a numeric expression. place a \ (back slash) character before the percent sign (see below).” The result string will include the thousand separator currently set up on the user's computer.).345. or the semi-colon (. The pattern parameter is a string of code characters. (period) . the period (.75 will produce a result string of “75%”. MapBasic 8. %. such as #. use the Set Format statement. The result will represent the value multiplied by one hundred. . a value of 0.5 . All rights reserved.67. pattern is a string which specifies how to format the results. these characters control how the results will look. The value parameter specifies the numeric value that you want to format. The table below summarizes the format characters.67”. To force the thousand separator to be a comma. Given a numeric value such as 12345. and if the value is between zero and one. 0 A digit placeholder similar to the # character. 0. The pattern string must include a period if you want the result string to include a “decimal separator. If the pattern string contains one or more 0 characters to the left of the decimal place. the formatted result string will include a zero before the decimal place.). thus. The pattern string must include a comma if you want the result string to include “thousand separators. but you do not want MapBasic to multiply the value by one hundred.). and the value is between zero and one. If the pattern string contains one or more # characters to the left of the decimal place. use the Set Format statement. chosen to produce a particular type of formatting. (comma) % 300 © 2006 MapInfo Corporation. To force the decimal separator to be a period.

345" "-12. Format$( 12345. "#.##. Format$(12345.##.#. All rights reserved.235e04" Reference Guide © 2006 MapInfo Corporation. Format$( 12345.235e+04" Format$( 0.#.6789.678.68" Format$(-12345.345.###E+00") ' returns "5. without causing the special formatting actions described above.345. a plus sign appears after the “e”.68" "$.234e+03”.($.#.#") "$#") "$#") ' ' ' ' returns returns returns returns "12. E- .345. By including a semicolon in your pattern string.Format$( ) function pattern character E+ Role in formatting results: The result is formatted with scientific notation. Format$(-12345.##)") 'returns "$12. Note: You will obtain slightly different results if your computer is set up with non-US number formatting.#.#") ".68)" ".##") ' returns "-$12.6789.678.###") ' returns "12.6789. "#.#") ' returns "12.($. %) in the results. Format$(12345.345" "$12345" "-$12345" Format$( 12345. the results include a minus sign after the “e”. include “–” in the second set of format characters. MapBasic does not perform any special processing for the character which follows the back slash. the value 1234 produces the result “1.345.##") ' returns "$12. except that the result will never show a plus sign following the “e”.679" ".#. This lets you include special characters (for example. The second set of format characters applies to negative numbers. For example. "$.054321.##)") 'returns "($12.678. (semi-colon) \ Error Conditions ERR_FCN_INVALID_FMT error generated if the pattern string is invalid Examples The following examples show the results you can obtain by using various pattern strings. "$. you can specify one format for positive numbers and another format for negative numbers. If the exponent is negative (which is the case for fractional numbers).#. Place the semicolon after the first set of format characters. "#. Format$(-12345. 301 .###E+00") ' returns "-1.#. If you want negative numbers to appear with a minus sign. "$. Format$(-12345. The results are shown as comments in the code. If the exponent is positive.345.432e-02" Format$(-12345. If the back slash character appears in a pattern string.#.345. ".7" Format$(-12345.68" Format$( 12345. This string of control characters functions just as the “E+” string. and before the second set of format characters.678.###E-00") ' returns "-1.6789.

5 . '-' for date separator.##\%") ' returns ".054321.05%" Format$(0.054321.##%") ' returns "5.054321. Syntax FormatDate$( value ) value is a number or string representing the date in a YYYYMMDD format. See DateWindow( ) function on page 229.43%" Format$(0. MapInfo Professional uses the current century or the century as determined by the Set Date Window statement. "0.054321.##\%") ' returns "0. Use the Date window to determine which century should be used. "#. "#. "#.432e-02" Format$(0. Examples Assuming Control Panel settings are d/m/y for date order. If you specify the year as a two-digit number (for example. Year can take two-digit year expressions.###E-00") ' returns "5.05%" See Also Str$( ) function FormatDate$( ) function Purpose Returns a date formatted in the short date style specified by the Control Panel.FormatDate$( ) function Format$( 0. 96). Return Value String Description The FormatDate$( ) function returns a string representing a date in the local system format as specified by the Control Panel. MapBasic 8. All rights reserved. and “dd-MMM-yyyy” for short date format: Dim d_Today As Date d_Today = CurDate( ) Print d_Today 'returns "19970910" Print FormatDate$(d_Today) 'returns "10-Sep-1997" Dim s_EnteredDate As String s_EnteredDate = "03-02-61" Print FormatDate$(s_EnteredDate) 'returns "03-Feb-1961" s_EnteredDate = "12-31-61" Print FormatDate$( s_EnteredDate ) ' returns ERROR: not d/m/y ordering s_EnteredDate = "31-12-61" Print FormatDate$( s_EnteredDate ) ' returns 31-Dec-1961" 302 © 2006 MapInfo Corporation.

67” (inserted a thousands separator) “12. Syntax FormatNumber$( num ) num is a numeric value or a string that represents a numeric value.67” (changed both characters to match the user's setup) FormatNumber$("12.345.345.345. Return Value String Description Returns a string that represents a number. and changed the decimal separator to match user's setup) “12.67” (inserted a thousands separator. including thousands separators and decimal-place separators that match the user's system configuration.67") Result returned “12. such as “1234. MapInfo Professional reads the user's system configuration to determine which characters to use as the thousands separator and decimal separator.67") FormatNumber$("12.56”.345.67") Reference Guide © 2006 MapInfo Corporation.67") Result returned “12. Examples The following table demonstrates how the FormatNumber$( ) function with a comma as the thousands separator and period as the decimal separator (United States defaults): Function Call FormatNumber$("12345. Set Date Window statement FormatNumber$( ) function Purpose Returns a string representing a number.345. this function inserts thousands separators. 303 .67” (no change) If the user's computer is set up to use period as the thousands separator and comma as the decimal separator. the following table demonstrates the results: Function Call FormatNumber$("12345.345. If the number is large enough to need a thousands separators.FormatNumber$( ) function See Also DateWindow( ) function. All rights reserved.

.. Browse.FrontWindow( ) function See Also DeformatNumber$( ) function FrontWindow( ) function Purpose Returns the integer identifier of the active window. Graph. Note that immediately following a statement which creates a new window (for example.5 . Browse. ] ) As return_type statement_list End Function name is the function name. WindowInfo( ) function Function… End Function statement Purpose Defines a custom function. Syntax FrontWindow( ) Return Value Integer Description The FrontWindow( ) function returns the integer ID of the foremost document window (Map. All rights reserved. the new window is the foremost window. Example Dim map_win_id As Integer Open Table "states" Map From states map_win_id = FrontWindow( ) See Also NumWindows( ) function. 304 © 2006 MapInfo Corporation. Map. Syntax Function name ( [ [ ByVal ] parameter As datatype ] [. Graph. MapBasic 8. [ ByVal ] parameter As datatype. Layout). or Layout). WindowID( ) function. Restrictions You cannot issue a Function…End Function statement through the MapBasic window.

every function call must include a pair of parentheses. However.. End Function Reference Guide © 2006 MapInfo Corporation. Any or all of a function's parameters may be specified as by-value if the optional ByVal keyword precedes the parameter name in the Function…End Function definition. statement_list is the list of statements that the function will execute. or Alias variables as ByVal parameters to custom functions. A user-defined function is similar to a Sub procedure. the function will always return a value of zero (if the function has a numeric data type). For example. the modified value will be reflected in the caller's variable. the function's caller can specify an expression for that parameter. Each Function…End Function definition must be preceded by a Declare Function statement.. arrays and custom Types are allowed. nor can a single function call return a set of values to fill in a custom data Type variable. regardless of whether the function takes parameters. When a parameter is declared by-value. You cannot pass arrays. if you wish to define a custom function called Foo. every parameter to a user-defined function is a byreference parameter. Restrictions on Parameter Passing A function call can return only one “scalar” value at a time.. such as integer. rather than having to specify the name of a single variable. Description The Function…End Function statement creates a custom. statement list goes here . or omit the parentheses entirely. or a null string (if the function has a string data type). there is no way for the function's caller to access the new value. All rights reserved. you can pass any of those data types as by-reference parameters. 305 .. your Function…End Function statement can either include an empty pair of parentheses. If the function modifies the value of a by-reference parameter. However. custom Type variables. in that any number of function calls may appear within one expression. If no value is assigned to name. Functions are more flexible. but a function returns a value. FALSE (if the function has a logical data type). your Function…End Function statement could either look like this: Function Foo( ) ' . However. This means that the function's caller must specify the name of a variable as the parameter. arrays and custom Types are not allowed. the following statement performs an assignment incorporating two calls to the Proper$( ) function: fullname = Proper$(firstname) + " " + Proper$(lastname) Within a Function…End Function definition. return_type is a standard scalar variable type. The value assigned to the name “variable” will be the value that is returned when the function is called. the function name parameter acts as a variable. For example. user-defined function. datatype is a variable type. a single function call cannot return an entire array's worth of values. User-defined functions may be called in the same fashion that standard MapInfo Professional functions are called.Function… End Function statement parameter is the name of a parameter to the function. In other words. if a function modifies the value of a byvalue parameter. If your custom function takes no parameters. By default.

any subsequent calls to the Abs function will execute the custom function instead of MapBasic's standard Abs( ) function. rather than the original.. In every procedure of that program. the re-definition applies throughout the entire application. in this fashion: var_name = Foo( ) Availability of Custom Functions The user may not incorporate calls to user-defined functions when filling in standard MapInfo Professional dialog boxes. statement list goes here . If you write a custom function which you wish to include in each of several MapBasic applications. this example uses the Declare Function statement to pre-define the CubeRoot function parameter list. all calls to the redefined function will use the custom function. Thus. which returns the cube root of a number (the number raised to the one-third power). customized version of the Distance( ) function. and you want each of your applications to use your own. other applications are not affected. CubeRoot.. If a program defines a custom function named Abs. such as Abs or Chr$. Declare Function CubeRoot(ByVal x As Float) As Float Declare Sub Main Sub Main Dim f_result As Float f_result = CubeRoot(23) 306 © 2006 MapInfo Corporation.. a compiled MapBasic program may issue a Select statement which does incorporate calls to user-defined functions. A custom function definition is only available from within the application that defines the function. End Function but all calls to the function would need to include the parentheses. Because the call to CubeRoot appears earlier in the program than the CubeRoot Function…End Function definition. MapBasic 8. All rights reserved. however. A custom function may only be called from within a compiled MapBasic application. When a MapBasic application redefines a standard function in this fashion. Thus. a user may not specify a user-defined function within the SQL Select dialog box. Such a custom function will replace the standard MapBasic function by the same name (within the confines of that MapBasic application).Function… End Function statement or like this: Function Foo ' . Function Names The Function…End Function statement's name parameter can match the name of a standard MapBasic function. you must copy the Function…End Function definition to each of the program files.5 . When a MapBasic application redefines a standard function. each of your applications must include the appropriate Function…End Function statement. if you are writing several separate applications.. Example The following example defines a custom function.

All rights reserved.. MunicipalitySubdivision = MunicipalitySubdiv_expr ] ] Output [ Into [ Table out_tablename [ Key out_keycolumn = in_keyexpr ] ] | [ Variable variable_name ]] [ Point [ On | Off ] [ Symbol Symbol_expr ]..33333333333 End Function See Also Declare Function statement. Longitude_column = Longitude Columns colname = geocoder_keyname [. SecondaryPostalCode = SecondaryPostalCode_expr. Placename_column = Placename. CountrySubdivision = CountrySubdiv_expr. Street2 = Street2_expr. [ IntersectingStreet = IntersectingStreet_expr ]. MunicipalitySubdiv_column = MunicipalitySubdivision. ] [ Street_column = Street. Latitude_column = Latitude. Placename = Placename_expr. CountrySubdiv_column = CountrySubdivision. ResultCode_column = ResultCode. Syntax Geocode connection_number Input [ Table input_tablename ] [ Country = Country_expr [ Street = Street_expr.] . SecondaryPostalCode_column = SecondaryPostalCode.] Reference Guide © 2006 MapInfo Corporation. 307 . Country_column = Country.Geocode statement Note Str$(f_result) End Sub Function CubeRoot(ByVal x As Float) As Float CubeRoot = x ^ 0. Municipality = Municipality_expr. Municipality_column = Municipality. CountrySecondarySubdiv_column = CountrySecondarySubdivision. PostalCode = PostalCode_expr. PostalCode_column = PostalCode. Sub…End Sub statement Geocode statement Purpose Geocodes a table or individual value using a remote geocode service through a connection created using the Open Connection statement and set up using the Set Connection Geocode statement. Declare Sub statement. CountrySecondarySubdivision= CountrySecondarySubdiv_expr.

Street2_expr is an expression that specifies a secondary address line. Municipality_column is a string the represents the name of the column to hold the Municipality result.Geocode statement [ Interactive [ On [ Max Candidates candidates_expr | All ] [ CloseMatchesOnly [ On | Off ] ] | Off [ First | None ]] connection_number is the number returned when the connection was created. Municipality_expr is an expression that specifies the name of a municipality. All rights reserved. such as a large building that may contain multiple addresses. 308 © 2006 MapInfo Corporation. IntersectingStreet_expr is an expression that specifies a street that should intersect with the street specified in Street_expr. PostalCode_expr is an expression that specifies a postal code. in_keyexpr is an expression from (the input table) whose value is inserted in the output record. in the US this corresponds to a county. Symbol_expr is an expression that specifies the symbol to use when displaying a Point from the geometry column. Country_expr is a string expression representing the three letter ISO code for the country. input_tablename is a table alias of an open table including result sets and selections. In the US this corresponds to a ZIP+4 extension on a ZIP Code. For example. CountrySecondarySubdiv_expr is an expression that specifies the name of a secondary subdivision for a country. CountrySubdivision_expr is an expression that specifies the name of a subdivision of a country. out_tablename is a table alias of a table to be used as the holder of the data resulting from the geocode operation. CountrySubdiv_column is a string the represents the name of the column to hold the Country Subdivision result. For example. Street_column is an alias that represents the name of the column to hold the Street result. In Canada it specifies the name of a province. This is used to identify the record from where the geocode came.5 . See Open Connection statement on page 434. out_keycolumn is a string representing the name of a key column in the output table that will be used to hold some identifying “key” from the input records. Placename_expr is an expression that specifies the name of a well-known place. See Symbol clause on page 651 for more information. in the US this specifies the name of a state. in Canada this corresponds to a census division. MapBasic 8. MunicipalitySubdiv_expr is an expression that specifies the name of a municipality subdivision. SecondaryPostalCode_expr is an expression that specifies a secondary postal code system. variable_name is the name of a variable that can hold a single geometry. Street_expr is an expression that specifies a street address.

ISO standard three letter country codes must be used. Latitude_column is a string the represents the name of the float or decimal column to hold the Latitude result. Description Every Geocode statement must include an Input clause and an Output clause. non-table. the more accurate your geocoding result will be. These items are documented by the specific geocoder. A Country must be specified either as an explicit argument or as a column in input_tablename. ResultCode_column is a string the represents the name of the column to hold the Result Code generated by the geocoder. Placename_column is a string the represents the name of the column to hold the Placename result. candidates_expr is an expression that specifies the number of candidates to be returned in an interactive geocoding session. The list of fields to include from input_table to be geocoded must include at least one value. however if a table is not specified. SecondaryPostalCode_column is a string the represents the name of the column to hold the Secondary Postal Code result. it can be a constant string if no data is available. colname is a string the represents the name of the column for a geocoder-specific result. See Table vs. Reference Guide © 2006 MapInfo Corporation. Longitude_column is a string the represents the name of the float or decimal column to hold the Longitude result. The output_tablename is also optional. The more expressions that are included. The input_ tablename is optional. the resulting geocode operation would be performed on a set of string inputs (variables or constants). All rights reserved. so that only a single address is geocoded in each request. CountrySecondarySubdiv_column is a string the represents the name of the column to hold the Country Secondary Subdivision result. 309 . Country_column is a string the represents the name of the column to hold the Country result. When a single country is used.based input and output below. geocoder_keyname is a string representing the name of a country-specific geocoder item. Input clause The Input clause is required as a geocode request needs some input data.Geocode statement PostalCode_column is a string the represents the name of the column to hold the Postal Code result. MunicipalitySubdiv_column is a string the represents the name of the column to hold the Municipality Subdivision result.

or into a variable. if multiple matches occur the choices are to accept the first candidate or none. This clause creates a relationship between the key columns in the input and output table. 310 © 2006 MapInfo Corporation. The default is skipping the record. If the output is a variable then only the first record is processed and the only value stored is the geographic object. non-table. the output can be placed either into a table or assigned to a variable. the user is prompted to choose. To store the point stored into the object column. Variable specifies that the geometry result from the geocode operation is stored in a variable defined in variable_name. When this occurs. The Columns extension allows for data to be returned that is geocoder specific. it may be possible to geocode an address with just a business name of “MapInfo” and a post code of “12180”. or constant strings. To return the same using a specific symbol. Key is used with Into Table. as without it. Point specifies that the geographic result of the geocode is to be stored in either the table or the variable. the clauses refer to the input_table. MapBasic 8. However. Table vs. For example. If you choose to use a table-based input you can have your output placed into either a new or existing table. If you do not want to store the point in the object column. the entire command returns nothing. When On. much more is returned in the output. The current default symbol is used. Interactive clause Interactive [ On | Off ] is an optional keyword that controls whether a dialog box to be displayed in the case of multiple candidates returned for each address. these may be more specific than the input. this requires that the table be mappable. the values for the operation must either be expressions (not column names). In the case of a table. When using this output option. which must be writable. skip. Note that if the input columns are to be updated.5 . The user must know the names of the keys as defined by the geocoders. the dialog box displays in these situations. they must be specified both for input AND output. When Off. or cancel the operation. If not specified. you can still store the x and y values in real number columns. is asked to decide which of the choices is best given the opportunity to skip this input. In general. specify Point Off. To do this specify those columns as Latitude = latitude_column Longitude = longitude_ column.based input and output The Geocode statement can be used with any combination of table-based and non-table-based inputs and outputs. specify Point On Symbol symbol_expr. variables. If you choose non-table-based input.Geocode statement Output clause The Output clause is required. The rest of the output data specifies columns in the output table where well known geocoder return values are stored. specify Point or Point On (default is on) . Whether you want the object created or not. meaning that the record is skipped. note that if the input is a table only the first record is processed and the remainder of the records are skipped. Into Table indicates that the Output clause refer to columns in output_table. All rights reserved. respecify.

Interactive On Max Candidates All returns all candidates Interactive On Max Candidates 4* myMBVariable/6 returns the number of candidates resulting from the evaluation of the expression. countrysubdivison="NY".32."MapInfo Cartographic". state. The CloseMatchesOnly setting sets the geocode service to only return close matches as defined by the server. Interactive Off is equivalent to Interactive Off None. StreetName=street Interactive on Max Candidates 5 The following example shows a Geocode request without using a table and outputting the results into a variable: Geocode connectionHandle Input street="1 Global View". If CloseMatchesOnly is set to Off.0). All rights reserved. 255 . countrysubdivision=state. When no value is provided for Max the default is three (3) candidates to be returned. Interactive Off First returns the first candidate in the list. If Interactive is specified. all results are returned up to the number defined in Max Candidates with the ones that are considered to be close marked as such. 255 .0). address=municipality This example shows a geocode request using the nystreets table and specifying a symbol for displaying the output. it is equivalent to Interactive Off None and no options can be specified.32. country="usa" Output Point Symbol MakeFontSymbol(65. country="usa" OUTPUT StreetName=street. postalcode=zip.24. the default is On. Streetname. 311 . and postalcode. municipality="Troy" Output Variable outvar See Also Open Connection statement Reference Guide © 2006 MapInfo Corporation.24. country="usa".Geocode statement If the Interactive keyword is not included. country="usa" Output Point Symbol MakeFontSymbol(65. street=StreetName. Geocode connectionHandle Input Table nystreets municipality=city. Examples The following example shows a geocode request using the nystreets table and specifying the use of the city."MapInfo Cartographic". StreetName=street This example sends a request with the Interactive set to On with the return value being placed into the street column. Geocode connectionHandle Input Table nystreets street=StreetName. Geocode connectionHandle Input Table nystreets street=StreetName. • • • • • Interactive is equivalent to Interactive On.

SmallInt. MapBasic 8. or String. indicating which type of information should be returned.DEF. Logical representing whether or not a match for CountrySecondarySubdivision is set. Integer. Logical. In addition. depending on the attribute parameter. GEOCODE_STREET_NUMBER GEOCODE_MUNICIPALITY GEOCODE_MUNICIPALITY2 GEOCODE_COUNTRY_SUBDIVISION GEOCODE_COUNTRY_SUBDIVISION2 GEOCODE_POSTAL_CODE 312 © 2006 MapInfo Corporation. Logical representing whether or not a match for MunicipalitySubdivision is set. Logical representing whether or not a match for StreetNumber is set. GeocodeInfo( ) can also return some status values from the last geocode command issued using each connection.5 . Logical representing whether or not a match for PostalCode is set. attribute is an Integer code. Logical representing whether a match for CountrySubdivision is set. Syntax GeoCodeInfo( connection_handle. attribute ) connection_handle is an Integer. Like many functions of this type in MapBasic. Logical representing whether or not a match for municipality is set. All the codes for these values are listed in MAPBASIC. All rights reserved. the return values vary according to the attribute parameter. attribute Value GEOCODE_STREET_NAME GeoCodeInfo( ) Return Value Logical representing whether or not a match for StreetName is set. Return Value Float.GeocodeInfo( ) function GeocodeInfo( ) function Purpose Returns any and all attributes that were set on a connection using the Set Connection Geocode statement. Description The GeoCodeInfo( ) function returns the properties defaulted by the connection or the properties that have been changed using Set GeoCode.

GEOCODE_FALLBACK_POSTAL GEOCODE_OFFSET_CENTER GEOCODE_OFFSET_CENTER_UNITS GEOCODE_OFFSET_END GEOCODE_OFFSET_END_UNITS GEOCODE_MIXED_CASE Reference Guide © 2006 MapInfo Corporation. String value representing the units of the offset from end of street value Logical representing whether MapInfo should format the strings returned in mixed case or leave them as uppercase. Float value representing the distance from the end of the road that the point is returned. The option uses a country specific algorithm that has knowledge of what address parts and what items should be capitalized and what should be made lower case. String value representing the units of the center of the road values. Logical representing whether or not the geocoder should fall back to a postal centroid when other options fail. This option may not be available for all countries. All rights reserved. Float value representing the distance from the center of the road that the point is returned. Logical representing whether or not the geocoder should fall back to a geographic centroid when other options fail.GeocodeInfo( ) function attribute Value GEOCODE_DICTIONARY GeoCodeInfo( ) Return Value SmallInt value representing one of these five values: • • • • • GEOCODE_BATCH_SIZE GEOCODE_FALLBACK_GEOGRAPHIC DICTIONARY_ALL DICTIONARY_ADDRESS_ONLY DICTIONARY_USER_ONLY DICTIONARY_PREFER_ADDRESS DICTIONARY_PREFER_USER Integer value representing the batch size. 313 .

5 . MapBasic 8. The actual request returned more than one close match for a particular record. Logical representing whether a column was not updated during the last operation because of a data type problem. The non-interactive command flag was to pick the first candidate returned rather than none. All rights reserved. Integer value representing the number of records not geocoded during the last operation. This flag only affects the behavior under the following circumstances: 1. String values alternately representing name and value for each passthrough pair. This forces MapInfo to pick one of the candidates. This value is used to know when to stop the enumeration of these values without error. 3. Integer specifying the number of passthrough items set on this connection. The case where this occurs is when integer columns are erroneously specified for nonnumeric postal codes. n is valid up to the value returned via GEOCODE_INFO_ PASSTHROUGH.GeocodeInfo( ) function attribute Value GEOCODE_RESULT_MARK_ MULTIPLE GeoCodeInfo( ) Return Value Logical representing whether MapInfo Professional should change the result code returned from the server by adding an indicator to the result code that the result was based on an arbitrary choice between multiple close matches. GEOCODE_COUNT_NOTGEOCODED GEOCODE_UNABLE_TO_CONVERT_ DATA GEOCODE_PASSTHROUGH GEOCODE_PASSTHROUGH + n See Also Open Connection statement. Set Connection Geocode statement 314 © 2006 MapInfo Corporation. There are two items for each pair. The geocoding was not interactive so no possibility of presenting the candidates dialog was possible. GEOCODE_COUNT_GEOCODED Integer value representing the number of records geocoded during the last operation. 2. (see Geocode command “First”).

If the Open File statement specified Random file access. then 4 bytes of the binary file will be read. the Get statement's Position clause can be used to indicate which record of data to read. Description The Get statement reads from an open file. If the Open File statement specified Binary file access. either 0 or non-zero. Four byte integer. Eight byte IEEE format. var_name is the name of a variable where MapBasic will store results. When the file is opened. The behavior of the Get statement and the set of parameters which it expects are affected by the options specified in the preceding Open File statement. position is the file position to read from. All rights reserved. the file position points to the first record of the file (record 1). and converted to a MapBasic variable. Four bytes: SmallInt year. 315 . Cannot be read. var_name filenum is the number of a file opened through an Open File statement. However.Get statement Get statement Purpose Reads from a file opened in Binary or Random access mode. Variables are stored the following way: Variable Type Logical SmallInt Integer Float String Date Other data types Storage In File One byte. byte day. one variable can be read at a time. Length of string plus a byte for a 0 string terminator. you can use the Position clause to set the record position before the record is read. Syntax Get [#] filenum. Reference Guide © 2006 MapInfo Corporation. [ position ]. byte month. What data is read depends on the byte-order format of the file and the var_name variable being used to store the results. If the variable type is integer. and thus the Position clause does not need to be used if sequential access is being performed. A Get automatically increments the file position. Two byte integer.

An example of a special MapInfo directory is the preference directory. See Also Open File statement. the position is set to one (the beginning of the file). As a Get is performed. Note that FOLDER_MI_APPDATA. Syntax GetFolderPath$( folder_id ) folder_id is one of the following values: FOLDER_MI_APPDATA FOLDER_MI_LOCAL_APPDATA FOLDER_MI_PREFERENCE FOLDER_MI_COMMON_APPDATA FOLDER_APPDATA FOLDER_LOCAL_APPDATA FOLDER_COMMON_APPDATA FOLDER_COMMON_DOCS FOLDER_MYDOCS FOLDER_MYPICS Return Value String Description Given the ID of a special MapInfo or Windows directory. FOLDER_MI_LOCAL_ APPDATA. any string variable used in a Get statement must be fixed-length. FOLDER_MI_ PREFERENCE always exists. test for their existence by using FileExists( ) function. If a file was opened in Binary mode. the position is incremented by the same amount read. Put statement GetFolderPath$( ) function Purpose Returns the path of a special MapInfo Professional or Windows directory. All rights reserved. the Get reads from where the file pointer is positioned. and FOLDER_MI_COMMON_APPDATA may not exist. the Get statement cannot specify a variable-length string variable. When the file is opened. The location of many of these directories varies between versions of Windows. MapBasic 8. An example of a special Windows directory is the My Documents directory. the default location to which MapInfo Professional writes out the preference file.GetFolderPath$( ) function With Binary file access. Before attempting to access those directories.5 . If the Position clause is not used. 316 © 2006 MapInfo Corporation. even if the optional position parameter is omitted. GetFolderPath$( ) function returns the path of the directory. Note: The Get statement requires two commas. They can also vary depending on which user is logged in. the position parameter is used to position the file pointer to a specific offset in the file.

MapInfo Professional returns an empty string. The rest of the IDs return the path for Windows directories and correspond to the IDs defined for WIN32 API function SHGetFolderPath. Any ID valid to SHGetFolderPath will work with GetFolderPath$( ). Example If the Parcels table has a metadata key called “\Copyright” then the following statement reads the key's value: Print GetMetadata$(Parcels. up to 239 bytes long. "\Copyright") Reference Guide © 2006 MapInfo Corporation. key_name ) table_name is the name of an open table. All rights reserved. Example include "mapbasic. Syntax GetMetadata$( table_name. key_name is a string representing the name of a metadata key. or see the MapBasic User Guide. For more information about querying a table's metadata.GetMetadata$( ) function IDs beginning in FOLDER_MI return the path for directories specific to MapInfo Professional. or if there is no value for the key. The most common of these IDs have been defined for easy use in MapBasic applications. Return Value String. see Metadata statement on page 381. specified either as an explicit table name (for example. “World”). Description This function returns a metadata value from a table.def" declare sub main sub main dim sMiPrfFile as string sMiPrfFile = GetFolderPath$(FOLDER_MI_PREFERENCE) Print sMiPrfFile end subet128 See Also LocateFile$( ) function GetMetadata$( ) function Purpose Retrieves metadata from a table. World) or as a string representing a table name (for example. 317 . If the key does not exist.

this function returns an empty string. TAB_INFO_SEAMLESS) Then s_sheet = GetSeamlessSheet(s_tab_name) If s_sheet <> "" Then Browse * From s_sheet End If Else Browse * from s_tab_name End If End Sub See Also Set Table statement. representing a table name (or an empty string if user cancels).5 . Example Sub Browse_A_Table(ByVal s_tab_name As String) Dim s_sheet As String If TableInfo(s_tab_name. and then returns the name of the chosen sheet. Syntax GetSeamlessSheet( table_name ) table_name is the name of a seamless table that is open. TableInfo( ) function 318 © 2006 MapInfo Corporation. All rights reserved. MapBasic 8. If the user chooses a sheet and clicks OK.GetSeamlessSheet( ) function See Also Metadata statement GetSeamlessSheet( ) function Purpose Prompts the user to select one sheet from a seamless table. If the user cancels. this function returns the table name the user selected. Return Value String. Description This function displays a dialog box listing all of the sheets that make up a seamless table.

Description A Global statement defines one or more global variables.. ReDim statement. the sub procedure's own local variables take precedence (i. In such a case. any references to the variable name will utilize the local variable. date. 319 . global variables are “visible” to other Windows applications through DDE conversations.. not the global variable by the same name).. the difference is that variables defined through a Global statement are global in scope. float. Global statements may only appear outside of a sub procedure. Global array variables may be re-sized with the ReDim statement. ] var_name is the name of a global variable to define. var_type is integer. string. logical. Type statement. whereas any sub procedure in a program may examine or modify any global variable. A local variable may only be examined or modified by the sub procedure which defined it. All rights reserved. A sub procedure may define local variables with names which coincide with the names of global variables.. while variables defined through a Dim statement are local. or a custom variable Type. The syntax of the Global statement is identical to the syntax of the Dim statement.Global statement Global statement Purpose Defines one or more global variables. within the sub procedure. Windows. ] As var_type. Syntax Global var_name [ ..e. var_name.. Example Declare Sub testing( ) Declare Sub Main( ) Global gi_var As Integer Sub Main( ) Call testing Note Str$(gi_var) ' this displays "23" End Sub Sub testing( ) gi_var = 23 End Sub See Also Dim statement. ] As var_type [ .. UBound( ) function Reference Guide © 2006 MapInfo Corporation. var_name.

. A Goto statement may only jump to a label within the same procedure.. Syntax Goto label label is a label appearing elsewhere in the same procedure. the Goto statement should not be used to exit a loop prematurely. the label name should appear in the Goto statement without the colon. The Exit Do statement and Exit For statement provide the ability to exit a loop.5 and later) Graph label_column. The label itself should be followed by a colon.. endproc: End Program See Also Do Case…End Case statement. however. Syntax (5. you should not use a Goto statement to jump into the body of a loop. expr [ .. Restrictions You cannot issue a Goto statement through the MapBasic window. Program execution continues at the statement line identified by the label. Description The Goto statement performs an unconditional jump. Example Goto endproc . Generally speaking.5 . For…Next statement. ] From table 320 © 2006 MapInfo Corporation. Do…Loop statement. Similarly. Resume statement Graph statement Purpose Opens a new Graph window. .Goto statement Goto statement Purpose Jumps to a different spot (in the same procedure). identified by a label. MapBasic 8. All rights reserved. OnError statement.

. expr [ ..0 graph is created. paperunits is the name of a paper unit (for example. in paper units. Otherwise a 5. in paper units. table is the name of an open table. table is the name of an open table. paperunits is the name of a paper unit (for example. Reference Guide © 2006 MapInfo Corporation. y ) [ Units paperunits ] ] [ Width window_width [ Units paperunits ] ] [ Height window_height [ Units paperunits ] ] [ Min | Max ] label_column is the name of the column to use for labelling the y-axis. in paper units. template_file is a valid graph template file.Graph statement [ [ [ [ [ Position ( x.5) Graph label_column. All rights reserved. so when the workspace is opened the title text is restored exactly as is was when the workspace was saved. 321 . then title text in the template file is used in the graph window. so the default text is used for each title. Syntax (pre-version 5. then a graph is created based on the specified template file. expr is an expression providing values to be graphed. The Restore keyword is included when writing the Graph command to a workspace. “in”). The Restore keyword is not used in the Graph command constructed by the Create Graph wizard. x. If the Restore clause is included. x. If Series In Columns is included.. window_width and window_height specify the size of the Grapher. then the graph series are based on the table columns. window_width and window_height specify the size of the Grapher. “in”). ] From table [ Position ( x. Description If the Using clause is present and template_file specifies a valid graph template file. Otherwise default text is used for each title in the graph. y ) [ Units paperunits ] ] Width window_width [ Units paperunits ] ] Height window_height [ Units paperunits ] ] Min | Max ] Using template_file [ Restore ] [ Series In Columns ] ] label_column is the name of the column to use for labelling the y-axis. y specifies the position of the upper left corner of the Grapher. Otherwise the series are based on the table rows. expr is an expression providing values to be graphed. in paper units. y specifies the position of the upper left corner of the Grapher.

5 or later. title.5 or later version graph window. however. MapBasic's Graph statement.). etc. Num_Hh_80 From States Using "C:\Program Files\MapInfo\GRAPHSUPPORT\Templates\Column\Percent. if the Graph statement includes the Min keyword. Conversely. Similarly. the resultant Grapher window is maximized. the graph rotation. Pop_1980.5 and later graphs) Graph State_Name. subsequent Set Graph statements can re-configure the specifics of the graph (for example.3tf" Graph City. MapInfo Professional 's Window > Graph dialog box is limited in that it only allows the user to choose column names to graph. the Graph statement can construct a graph with up to 255 columns. displaying the specified table. taking up all of the screen space available to MapInfo Professional.0 graph window is active in MapInfo Professional 5. so the user can modify the graph using the 5.5 will still create a 5. MapBasic 8.0 graph menu will be also be active. Pop_1990. When a 5. the window is minimized. The Create Graph wizard will always created a 5. although the Graph dialog box only allows the user to choose four columns to graph. graph type. The graph will appear as a rotated bar chart. Population From Selection See Also Set Graph statement 322 © 2006 MapInfo Corporation. If the Graph statement includes the optional Max keyword. is able to graph full expressions which involve column names.Graph statement Graph commands in workspaces or programs that were created prior to version 5.5 . Tot_hu. Tot_pop From City_125 Using "C:\Program Files\MapInfo\GRAPHSUPPORT\Templates\Bar\Clustered. the 5.5 graphs) Graph Country. All rights reserved.3tf" Series In Columns Example (pre-5. Example (5.0 graph window.0 editing dialog boxes. The Graph statement adds a new Grapher window to the screen.

323 . such as SYSTEM. ProgramDirectory$( ) function. SystemInfo( ) function If…Then statement Purpose Decides which block of statements to execute (if any). Syntax If if_condition Then if_statement_list [ ElseIf elseif_condition Then elseif_statement_list ] Reference Guide © 2006 MapInfo Corporation. This is the directory containing Windows system files. Syntax HomeDirectory$( ) Return Value String Description The HomeDirectory$( ) function returns a string which indicates the user's home directory path. based on the current value of one or more expressions. The table below summarizes the platform-dependent home directory path definitions.HomeDirectory$( ) function HomeDirectory$( ) function Purpose Returns a string indicating the user's home directory path.INI and WIN. All rights reserved. to allow each user to have a unique configuration. In a networked environment.INI. each user has a private Windows directory. Environment Windows Definition of “Home Directory” The directory path to the user's Windows directory. Example Dim s_home_dir As String s_home_dir = HomeDirectory$( ) See Also ApplicationDirectory$( ) function. The significance of a home directory path depends on the hardware platform on which the user is running.

In its simplest form. otherwise. If the if_ condition is TRUE. if that condition is TRUE. following the If clause (and preceding the optional Else clause): If if_condition Then if_statement_list ElseIf elseif_condition Then elseif_statement_list Else else_statement_list End If With this arrangement. MapBasic 8. 324 © 2006 MapInfo Corporation. But if that condition is FALSE.. MapBasic evaluates the if_condition at run-time. nor an Else clause: If if_condition Then if_statement_list End If With this arrangement. MapBasic will execute the elseif_statement_list. MapBasic executes the if_statement_list. If the if_condition is TRUE.. MapBasic will either execute the if_statement_list (if the condition is TRUE) or the else_statement_list (if the condition is FALSE). Additionally. MapBasic skips the if_statement_list. and then jump down to the statement which follows the End If. An If statement may also include the optional Else clause: If if_condition Then if_statement_list Else else_statement_list End If With this arrangement. continuing until either one of the conditions turns out to be TRUE or until the Else clause or the End If is reached. MapBasic will perform the if_statement_list.If…Then statement [ ElseIf . an If statement may include one or more ElseIf clauses. MapBasic tests a series of two or more conditions. Description The If…Then statement allows conditional execution of different groups of statements. ] [ Else else_statement_list ] End If Each condition is a condition which will evaluate to TRUE or FALSE Each statement_list is a list of zero or more statements. MapBasic then evaluates the else_if_condition. Restrictions You cannot issue an If…Then statement through the MapBasic window. the If statement does not include an ElseIf clause. All rights reserved.5 .

thus allowing you to test any number of possible conditions. PICT files. Example Dim today As Date Dim today_mon. such as a GML or DXF file. 325 . yearcount As Integer today = CurDate( ) ' get current date today_mon = Month(today) ' get the month value today_day = Day(today) ' get the day value (1-31) If today_mon = 1 And today_day = 1 Then Note "Happy New Year!" yearcount = yearcount + 1 ElseIf today_mon = 2 And today_day = 14 Then Note "Happy Valentine's Day!" ElseIf today_mon = 12 And today_day = 25 Then Note "Merry Christmas!" Else Note "Good day. today_day. All rights reserved.Import statement An If statement may include two or more ElseIf clauses. or MapInfo for DOS files) Import file_name [ Type file_type ] [ Into table_name ] [ Overwrite ] Syntax 2 (for importing DXF files) Import file_name [ Type "DXF" ] [ Into table_name ] [ Overwrite ] [ Warnings { On | Off } ] [ Preserve [ AttributeData ] [ Preserve ] [ Blocks As MultiPolygonRgns ] ] [ CoordSys. However.. Syntax 1 (for importing MIF/MID files.. the Do Case…End Case statement is more elegant than an If statement with many ElseIf clauses." End If See Also Do Case…End Case statement Import statement Purpose Creates a new MapInfo Professional table by importing an exported file. if you are testing for one out of a large number of possible conditions. ] [ Autoflip ] Reference Guide © 2006 MapInfo Corporation.

etc. the new table's default name is “WORLD. on Windows.TAB”. if you import the text file “WORLD. All rights reserved. MI_y2 ) ] [ Read [ Integer As Decimal ] [ Read ] [ Float As Decimal ] ] [ Store [ Handles ] [ Elevation ] [ VisibleOnly ] ] [ Layer DXF_layer_name [ Into table_name ] [ Preserve [ AttributeData ] [ Preserve ] [ Blocks As MultiPolygonRgns ] ] ] [ Layer. layer_name is a string representing the name of a layer in the GML file. the new table is created in the same directory location as the original file..1 files) Import file_name [ Type "GML21" ] [ Layer layer_name] [ Into table_name ] [ Overwrite ] [ CoordSys. etc. Description The Import statement creates a new MapInfo table by importing the contents of an existing file. use the Register Table statement. table_name specifies the name of the new table to create. The Into clause lets you override the name and location of the MapInfo table that is created. or PICT). MBI. DXF_layer_name is a string representing the name of a layer in the DXF file. MI_x1.5 . For example. MMI. file_type is a string that specifies the import file format (MIF. are numbers that represent coordinates in the MapInfo table... Note: To create a MapInfo table based on a spreadsheet or database file. ] Syntax 3 (for GML files) Import file_name [ Type "GML" ] [ Layer layer_name ] [ Into table_name ] [ Style Auto [ On | Off ] ] Syntax 4 (for GML 2.Import statement [ Transform ( DXF_x1. MI_y1 ) ( MI_x2. are numbers that represent coordinates in the DXF file. not the Import statement. DXF_y1. MI_y1.. DXF_y1 ) ( DXF_x2. DXF_x1. If no Into clause is specified.MIF”. MapBasic 8. ] file_name is a string that specifies the name of the file to import. with a corresponding file name. DXF_y2 ) ( MI_x1. 326 © 2006 MapInfo Corporation. GML GML21. IMG.

created by MapInfo for DOS. created by exporting a MapInfo table. The Type clause can take one of the following forms: Type clause Type “DXF” Type “MIF” Type “MBI” Type “MMI” Type “IMG” Type “GML” Type “GML21” File Format Specified DXF file (a format supported by CAD packages. warnings are off. Note: The order of the clauses is important. If you omit the Type clause. MapInfo Professional assumes that the file's extension indicates the file format. created by MapInfo for DOS. MapInfo Map Interchange. and the table already exists. created by MapInfo for DOS. MapInfo Professional does not overwrite the table. Reference Guide © 2006 MapInfo Corporation. Import Options for DXF Files If you import a DXF file.DXF” is assumed to be a DXF file. such as AutoCAD). If you omit this clause.1 files. placing the clauses in the wrong order can cause compilation errors. MapInfo Professional creates a new table.Import statement The optional Type clause specifies the format of the file you want to import. By default. Preserve Blocks As MultiPolygonRgns Include this clause if you want MapInfo Professional to store all of the polygons from a DXF block record into one multiple-polygon region object. If you include the optional Overwrite keyword. 327 . the new table replaces the existing table. the Import statement can include the following DXF-specific clauses. MapInfo Boundary Interchange. each DXF polygon becomes a separate MapInfo Professional region object. MapInfo Image file. a file named “PARCELS. MIF/MID file pair. For example. All rights reserved. GML files GML 2. Preserve AttributeData Include this clause if you want MapInfo Professional to preserve the attribute data from the DXF file. Warnings On or Warnings Off Controls whether warning messages are displayed during the import operation. regardless of whether a table by that name already exists. If you omit the Overwrite keyword.

This clause is only allowed when you include the Preserve AttributeData clause. Transform Specifies a coordinate transformation. MapInfo Professional stores the elevation at the center of the line. and you specify the minimum and maximum coordinates that you want to have in the MapInfo table. Read Integer As Decimal Include this clause if you want to store whole numbers from the DXF file in a decimal column in the new table. This clause is only allowed when you include the Preserve AttributeData clause. MapInfo Professional ignores invisible objects. suppose your DXF file contains four layers (layers 0. the MapInfo table stores handles (unique ID numbers of objects in the drawing) in a column called _DXFHandle. Layer clause If you do not include any Layer clauses. For example. All rights reserved. The following Import statement imports all four layers into a single MapInfo table: Import "FLOORS. Autoflip Include this option if you want the map's x-coordinates to be flipped around the center line of the map. MapInfo Professional only imports the layers that you name. see CoordSys clause on page 161. MapBasic 8. Read Float As Decimal Include this clause if you want to store floating-point numbers from the DXF file in a decimal column in the new table. for regions. For details.DXF" Into "FLOORS. If your DXF file contains multiple layers. MapInfo Professional stores the average of the object's elevation values. If you include one or more Layer clauses. and if your Import statement includes one or more Layer clauses. 2. In the Transform clause. If you include Elevation. Store [Handles] [Elevation] [VisibleOnly] If you include Handles. you specify the minimum and maximum x. MapInfo Professional stores each object's center elevation in a column called _DXFElevation. (For lines.TAB" Preserve AttributeData 328 © 2006 MapInfo Corporation. This option is only allowed if you specify a non-Earth coordinate system.5 . each DXF layer that you name becomes a separate MapInfo table.and y-coordinates of the imported file.) If you include VisibleOnly. all objects from the DXF file are imported into a single MapInfo table.Import statement CoordSys Controls the projection and coordinate system of the table. 1. and 3).

MapInfo Professional only imports attribute data. It will not transform the data from one projection to another. If the GML file contains a supported projection and the Coordsys clause is not specified. If the GML file contains a supported projection and the Coordsys clause is specified.DXF" Layer "1" Into "FLOOR_1. The coordinate system must match the coordinate system of the data in the GML file. If Overwrite is not specified.Import statement The following statement imports layers 1 and 3. the projection from the GML file will be used. 329 . All rights reserved. and Boundary Line are supported. table_name is the MapInfo table name. If topological objects are included in the file.gml" Type "GML" layer "LandformArea" style auto on Into "D:\midata\GML\est_LandformArea. Note: If the Coordsys clause does not match the projection of the GML file. If the files contains XLINKS. Examples Sample importing using GML style: Import "D:\midata\GML\est.TAB" Preserve AttributeData Importing GML Files MapInfo Professional supports importing OSGB (Ordnance Survey of Great Britain) GML files. Cartographic Text is not supported. but does not import layers 0 or 2: Import "FLOORS. Access the Browser view to see the display of attribute data. MapInfo Professional supports the non-topological form. Type is “GML21” for GML 2. Cartographic Symbol. a warning displays indicating that spatial objects cannot be imported. the Coordsys clause must be specified.TAB" Overwrite Sample importing using GML21 style: Reference Guide © 2006 MapInfo Corporation. Topographic Point. Topographic Line. Topographic Area. If the GML file does not contain a supported projection.1 files. the projection from the Coordsys clause will be used. layer_name is the name of the GML layer. your data may not import correctly.1 file to import. an error will result if the TAB file already exists. These XLINKs are stored in the GML file as “xlink:href=”. and does not import spatial objects. The Coordsys clause is optional. Topographic Area can be distributed in two forms.TAB" Preserve AttributeData Layer "3" Into "FLOOR_3. Importing GML Files file_name is the name of the GML 2. Overwrite causes the TAB file to be automatically overwritten.

Include statement Import "D:\midata\GML\GML2. This arrangement allows you to leave standard definitions files. MapBasic 8. Restrictions You cannot issue an Include statement through the MapBasic window. Syntax Include "filename" filename is the name of an existing text file.1\mi_usa. MAPBASIC. which is provided with MapBasic.xml" Type "GML21" layer "USA" Into "D:\midata\GML\GML2.DEF.TAB" Overwrite The following example imports a MIF (MapInfo Interchange Format) file: Import "WORLD. The most common use of the Include statement is to include the file of standard MapBasic definitions. containing only legitimate MapBasic statements. in one directory. rather than copying the definitions files to the directories where you keep your program files. 104 Sample importing using current MapInfo style: Import "D:\midata\GML\test. defines a number of important identifiers.gml" Type "GML" layer "TopographicLine" style auto off Into "D:\midata\GML\test_TopographicLine. and if the specified file does not exist in the current directory. 330 © 2006 MapInfo Corporation. the MapBasic compiler looks for the file in the program directory. such as TRUE and FALSE.1\mi_usa_USA.tab" Map From world_2 See Also Export statement Include statement Purpose Incorporates the contents of a separate text file as part of a MapBasic program.TAB" Overwrite CoordSys Earth Projection 1. This file. such as MAPBASIC. Description When MapBasic is compiling a program file and encounters an Include statement. If the filename parameter does not specify a directory path. the entire contents of the included file are inserted into the program file.MIF" Type "MIF" Into "world_2.5 . The file specified by an Include statement should be a text file. All rights reserved.DEF.

if the end-of-file was reached before the input was completed. After issuing an Input # statement. For an example of the Input # statement. MapInfo Professional treats commas and end-of-line characters as field delimiters. and stores the data in one or more MapBasic variables. ] filenum is the number of a file opened through the Open File statement. call the EOF( ) function to determine if MapInfo Professional was able to read the data. Syntax Input # filenum. 331 . var_name. The Input # statement reads data (up to the next end-of-line) into the variable(s) indicated by the var_name parameter(s). var_name is the name of a variable. Write # statement Reference Guide © 2006 MapInfo Corporation. To read an entire line of text into a single string variable. Description The Input # statement reads data from a file which was opened in a sequential mode (for example.. the Input # statement treats a blank line as a zero value. Open File statement. When reading data into a string variable. use Line Input statement. var_name [ . you should then recompile any MapBasic programs which Include that file.. and stores the data in variables. see the sample program NVIEWS (Named Views).DEF" Input # statement Purpose Reads data from a file. Example Include "MAPBASIC. Line Input statement. The following data types are not available with the Input # statement: • • • • • • Alias Pen Brush Font Symbol Object See Also EOF( ) function. All rights reserved. If the input was successful. the Input # statement treats a blank line as an empty string. INPUT mode). the EOF( ) function returns FALSE. MapBasic automatically converts the data to the type of the variable(s). When reading data into a numeric variable.Input # statement Whenever you change the contents of a file that you use through an Include statement. the EOF( ) function returns TRUE.

and we provide MapBasic with a value for each of those columns. we know that the table has four columns (Name. allowing you to either add one row at a time. All rights reserved. Description The Insert statement inserts new rows into an open table. Syntax Insert Into table [ ( columnlist ) ] { Values ( exprlist ) | Select columnlist From table } table is the name of an open table. comma-separated. "TX") The preceding statement would generate an error at run-time if it turned out that the table had fewer than (or more than) four columns. and if you have values to store in each of those columns. MapBasic 8. all fields are assumed. Address. regardless of how many columns are in the table. In the following example. In cases where you do not know exactly how many columns are in a table or the exact order in which the columns appear. Here. or insert groups of rows from another table (via the Select clause). Examples The following example inserts a new row into the customer table. columnlist is a list of column expressions. If no column list is specified. Insert Into customers (Name) Values ("Steve Harris") 332 © 2006 MapInfo Corporation. "Dallas".5 . the one value specified by the Values clause will be stored in the “Name” column. and regardless of the position of the “Name” column in the table structure. "23 Main St". the number of column values inserted must match the number of columns in the column list. There are two main forms of this statement. then you do not need to specify the optional columnlist clause. If you know exactly how many columns are in the table you are modifying. Note that you must use a Commit Table statement if you want to permanently save newly-inserted records to disk.Insert statement Insert statement Purpose Appends new rows to an open table. comma-separated. Insert Into customers Values ("Mary Ryan". while providing only one column value for the new row. and State). City. thus. exprlist is a list of one or more expressions. In either case. you should use the optional columnlist clause. all other columns in the new row will initially be blank.

substring ) position is a positive integer. Note that Obj is a special column name representing the table's graphical objects. indicating where a substring first appears within another string. Syntax InStr( position. then insert each object as a new record in the table Outline. Delete statement. Open Table "world" Open Table "outline" Insert Into outline (Obj) Select Obj From World See Also Commit Table statement. 333 . Rollback statement InStr( ) function Purpose Returns a character position. All rights reserved.InStr( ) function The following statement creates a point object and inserts the object into a new row of the Sites table. 42. for convenience's sake (since operations such as Find can only work with one table at a time). string is a string expression. In this example. we assume that the table NY_ZIPS contains ZIP Code boundaries for New York state. We want to put all ZIP Code boundaries into a single table. Return Value Integer Reference Guide © 2006 MapInfo Corporation. and NJ_ZIPS contains ZIP Code boundaries for New Jersey. we select the graphical objects from the table World. the Insert statement below appends all of the records from the New Jersey table into the New York table. Insert Into NY_ZIPS Select * From NJ_ZIPS In the following example. Accordingly.8) ) The following example illustrates how the Insert statement can append records from one table to another.5. Insert Into sites (Obj) Values ( CreatePoint(-73. substring is a string expression which we will try to locate in string. indicating the start position of the search. string.

"York") ' pos will now contain a value of 5 (five) pos = InStr(1. if the substring appears at the very start of the string. In other words. because “BC” is upper-case. Error Conditions ERR_FCN_ARG_RANGE error generated if an argument is outside of the valid range Example Dim fullname As String. so InStr will not locate it ' within the string "New York City" See Also Mid$( ) function Int( ) function Purpose Returns an integer value obtained by removing the fractional part of a decimal value. MapBasic will search from the very beginning of the string parameter. the InStr( ) function returns the character position where the substring appears. The InStr( ) function is case-sensitive. thus. fullname. "YORK") ' pos will now contain a value of 0. if the position parameter has a value of one. If string does contain substring. If the substring parameter is a null string. the InStr( ) function cannot locate the substring “BC” within the larger string “abcde”. MapBasic searches the string expression. Syntax Int( num_expr ) num_expr is a numeric expression.Int( ) function Description The InStr( ) function tests whether the string expression string contains the string expression substring. Return Value Integer 334 © 2006 MapInfo Corporation. the InStr( ) function returns zero. ' YORK is uppercase. MapBasic 8. pos As Integer fullname = "New York City" pos = InStr(1.5 . InStr( ) will return a value of one. fullname. starting at the position indicated by the position parameter. All rights reserved. For example. If string does not contain substring. the InStr( ) function returns a value of zero.

Round( ) function IntersectNodes( ) function Purpose Calculates the set of points at which two objects intersect.3) will return a value of -2. Fix( ) function will return the nearest integer value greater than or equal to the original value. and returns a polyline object that contains each of the points of intersection.3) returns a value of -3. it returns the nearest integer value that is less than or equal to the original value. 335 .999) ' whole now has the value 5 whole = Int(-7. Reference Guide © 2006 MapInfo Corporation. may not be point or text objects. All rights reserved. So. But when the Int( ) function is passed a negative fractional number. The two functions differ in the way that they treat negative fractional values. Description The IntersectNodes( ) function returns a polyline object that contains all nodes at which two objects intersect. points_to_include is one of the following SmallInt values: • • • INCL_CROSSINGS returns points where segments cross. but not identical to.2) ' whole now has the value -8 See Also Fix( ) function. so. The Fix( ) function is similar to. points_to_include ) object1 and object2 are object expressions.IntersectNodes( ) function Description The Int( ) function returns the nearest integer value that is less than or equal to the specified num_ expr expression. Return Value A polyline object that contains the specified points of intersection. INCL_ALL returns points where segments cross and points where segments overlap. object2. the function call Fix(-2. Syntax IntersectNodes( object1. Example Dim whole As Integer whole = Int(5. the function call Int(-2. the Int( ) function. INCL_COMMON returns end-points of segments that overlap. When passed a negative fractional number.

Logical. There are several attributes that IsogramInfo( ) can return. attribute ) connection_handle is an integer signifying the number of the connection returned from the Open Connection statement. attribute is an Integer code.5 . Codes are defined in MAPBASIC. indicating which type of information should be returned. All rights reserved. or String. depending on the attribute parameter. Float value representing the Maximum off Road Distance value The unit string associated with the value ISOGRAM_RETURN_HOLES ISOGRAM_MAJOR_POLYGON_ONLY ISOGRAM_MAX_OFF_ROAD_DISTANCE ISOGRAM_MAX_OFF_ROAD_DISTANCE_ UNITS ISOGRAM_SIMPLIFICATION_FACTOR Float value representing the Simplification Factor. Return Value Float. Syntax IsogramInfo( connection_handle. MapBasic 8. (a percent value represented as a value between 0 and 1 336 © 2006 MapInfo Corporation. attribute setting ISOGRAM_BANDING ISOGRAM_MAJOR_ROADS_ONLY IsogramInfo( ) Return Value Logical representing the Banding option Logical representing the MajorRoadsOnly option Logical representing the choice of returning regions with holes or not.DEF.IsogramInfo( ) function IsogramInfo( ) function Purpose Returns any and all attributes that were set on a connection using the Set Connection Isogram statement. Description This function returns the properties defaulted by the connection or the properties that have been changed using the Set Connection Isogram statement. Logical representing the choice of returning only the main polygon of a region.

“min”.16. Syntax IsPenWidthPixels( penwidth ) Reference Guide © 2006 MapInfo Corporation. Integer value representing the number of records NOT inserted in the last command. Integer value representing the maximum number of records that are sent to the service at one time. “sec”). String value representing the time unit (“hr”. Roads not identified in the network can be driveways or access roads. Integer value representing the number of records inserted in the last command. Logical representing the whether or not records that contain non-point objects should be skipped. String value representing the distance unit (“mi”. The propagation factor is a percentage of the cost used to calculate the distance between the starting point and the Distance. ISOGRAM_DEFAULT_AMBIENT_SPEED_ DISTANCE_UNIT ISOGRAM_DEFAULT_AMBIENT_SPEED_ TIME_UNIT ISOGRAM_DEFAULT_PROPAGATION_ FACTOR ISOGRAM_BATCH_SIZE ISOGRAM_POINTS_ONLY ISOGRAM_RECORDS_INSERTED ISOGRAM_RECORDS_NOTINSERTED See Also Create Object statement. The default value for this property is 0. 337 . among others. All rights reserved. Open Connection statement. Set Connection Isogram statement IsPenWidthPixels( ) function Purpose The IsPenWidthPixels function determines if a pen width is in pixels or in points. “km”).IsPenWidthPixels( ) function attribute setting ISOGRAM_DEFAULT_AMBIENT_SPEED IsogramInfo( ) Return Value Float value representing the default ambient speed. Determines the off-road network percentage of the remaining cost (distance) for which off network travel is allowed when finding the Distance boundary.

Pen clause. The pen width for a line may be determined using the StyleAttr( ) function. All rights reserved. the Kill statement should be used with caution. optionally. There is no “undo” operation for a Kill statement. Syntax Kill filespec filespec is a string which specifies a filename (and. Return Value True if the width value is in pixels. Return Value String Description The Kill statement deletes a file from the disk.TXT" 338 © 2006 MapInfo Corporation. Description The IsPenWidthPixels( ) function will return TRUE if the given pen width is in pixels. Example Include "MAPBASIC.5 .DEF" Dim CurPen As Pen Dim Width As Integer Dim PointSize As Float CurPen = CurrentPen( ) Width = StyleAttr(CurPen. False if the width value is in points. StyleAttr( ) function Kill statement Purpose Deletes a file.Kill statement penwidth is a small integer representing the pen width. Therefore. MapBasic 8. MakePen( ) function. Example Kill "C:\TEMP\JUNK. PEN_WIDTH) If Not IsPenWidthPixels(Width) Then PointSize = PenWidthToPoints(Width) End If See Also CurrentPen( ) function. the file's path). PenWidthToPoints( ) function.

1 for the top layer). b_mapper is a logical value.. and then determines whether a label was drawn for a specific row in the table. indicating the row number of the row whose label you wish to query. specify the name of the member table. and you can query the label by calling the Labelinfo( ) function. table is a table name or an empty string (""): when you query a table that belongs to a seamless table. otherwise. 339 . b_mapper ) map_window_id is an integer window id. Example The following example maps the World table. layer_number is the number of a layer in the current Map window (for example. displays automatic labels. All rights reserved.def" Dim b_morelabels As Logical Dim i_mapid As Integer Dim obj_mytext As Object Open Table "World" Interactive As World Map From World i_mapid = FrontWindow( ) Set Map Window i_mapid Layer 1 Label Auto On ' Make sure all labels draw before we continue.. specify FALSE to query the labels that appear when the map is inside a Layout. so that you can query the label for a specific row in a map layer. row_id. If the return value is TRUE. row_id is a positive integer value. layer_number. Specify TRUE to query the labels that appear when the Map is active. specify an empty string. Description Call LabelFindByID( ) when you want to query the label for a specific row in a map layer. Syntax LabelFindByID( map_window_id. then a label exists for the row. identifying a Map window. Include "mapbasic. table. Update Window i_mapid Reference Guide © 2006 MapInfo Corporation. Return Value Logical value: TRUE means that a label exists for the specified row.LabelFindByID( ) function See Also Open File statement LabelFindByID( ) function Purpose Initializes an internal label pointer.

or you could query it by ' calling ObjectInfo( ) or ObjectGeography( ). 340 © 2006 MapInfo Corporation. or the user has edited labels. 1. and those edited labels are not currently visible). Set MapBasic's internal label pointer by calling the LabelFindFirst( ) function. layer_number is the number of a layer in the current Map window (for example. TRUE) If b_morelabels Then ' The object was labeled. All rights reserved. see Labelinfo( ) function on page 341. LABEL_INFO_OBJECT) ' At this point. layer_number. Syntax LabelFindFirst( map_window_id. To continue querying additional labels. 1. Return Value Logical value: TRUE means that labels exist for the specified layer (either labels are currently visible. the LabelFindNext( ) function. b_mapper ) map_window_id is an integer window id. 1 for the top layer). identifying a Map window. Querying labels is a two-step process: 1. "". 1. b_mapper is a logical value.LabelFindFirst( ) function ' Now see if row # 1 was auto-labeled b_morelabels = LabelFindByID(i_mapid. specify FALSE to query the labels that appear when the map is inside a Layout. Description Call LabelFindFirst( ) when you want to loop through a map layer's labels to query the labels. 2.5 . so that you can query the first label in a map layer. you could save the obj_mytext object ' in a permanent table. MapBasic 8. you can query the current label by calling the Labelinfo( ) function. End If See Also LabelFindFirst( ) function. return to step 1. If the function you called in step 1 did not return FALSE. now query its label. LabelFindNext( ) function. or the LabelFindByID( ) function. Labelinfo( ) function LabelFindFirst( ) function Purpose Initializes an internal label pointer. Example For an example. obj_mytext = LabelInfo(i_mapid. Specify TRUE to query the labels that appear when the Map is active.

Reference Guide © 2006 MapInfo Corporation. identifying a Map window. so that you can query the next label in a map layer. 341 . See Also LabelFindByID( ) function. layer_number is the number of a layer in the current Map window (for example. 1 for the top layer). LabelFindNext( ) function. FALSE means there are no more labels for this layer. attribute is a code indicating the type of information to return. layer_number. Description After you call the LabelFindFirst( ) function to begin querying labels. identifying a Map window. LabelFindFirst( ) function. Labelinfo( ) function LabelFindNext( ) function Purpose Advances the internal label pointer. Labelinfo( ) function Labelinfo( ) function Purpose Returns information about a label in a map. attribute ) map_window_id is an integer window id. Syntax Labelinfo( map_window_id. see table below. Syntax LabelFindNext( map_window_id. All rights reserved. you can call LabelFindNext( ) to advance to the next label in the same layer. 1 for the top layer). Example For an example. Return Value Logical value: TRUE means the label pointer was advanced to the next label. see Labelinfo( ) function on page 341. layer_number is the number of a layer in the current Map window (for example.LabelFindNext( ) function See Also LabelFindByID( ) function. layer_number ) map_window_id is an integer window id.

Note: Labels are different than text objects. indicating the x-coordinate of the label's anchor location.5 . codes are defined in MAPBASIC. Logical value. TRUE if label's rotation angle has been modified. All rights reserved. TRUE if callout line's Pen style has been modified. Logical value. Logical value. TRUE if label's font has been modified. TRUE if label visibility has been set to OFF. TRUE if label is currently visible. attribute code LABEL_INFO_ANCHORX Labelinfo( ) Return Value Float value. Before calling Labelinfo( ). indicating the y-coordinate of the label's anchor location. TRUE if label's offset has been modified. Logical value. or the LabelFindByID( ) function. To query a text object. The attribute parameter must be one of the codes from the following table. Logical value. Logical value. MapBasic 8. LABEL_INFO_ANCHORY LABEL_INFO_DRAWN LABEL_INFO_EDIT LABEL_INFO_EDIT_ANCHOR LABEL_INFO_EDIT_ANGLE LABEL_INFO_EDIT_FONT LABEL_INFO_EDIT_OFFSET LABEL_INFO_EDIT_PEN LABEL_INFO_EDIT_POSITION LABEL_INFO_EDIT_TEXT LABEL_INFO_EDIT_ TEXTARROW LABEL_INFO_EDIT_TEXTLINE LABEL_INFO_EDIT_VISIBILITY 342 © 2006 MapInfo Corporation. TRUE if label's text has been modified. Logical value. Logical value. Logical value. See the example below. Logical value. Logical value. TRUE if label has been moved. TRUE if label's position (relative to anchor) has been modified. you must initialize MapBasic's internal label pointer by calling the LabelFindFirst( ) function. Logical value. TRUE if label's text arrow setting has been modified. call functions such as ObjectInfo( ) function or ObjectGeography( ) function. TRUE if callout line has been moved. TRUE if label has been edited.DEF. the LabelFindNext( ) function. Description The Labelinfo( ) function returns information about a label in a Map window. Float value.Labelinfo( ) function Return Value Return value depends on attribute.

LABEL_INFO_SELECT LABEL_INFO_TABLE Example The following example shows how to loop through all of the labels for a row. its position is 8. Useful if you are using seamless tables and you need to know which member table owns the label. ' and assign a layer number to i_layernum. String value. LAYER_INFO_LBL_POS_TR (3). representing the name of the table that owns this label. LAYER_INFO_LBL_POS_TL (1). TRUE if label is selected. TRUE) Do While b_morelabels Reference Guide © 2006 MapInfo Corporation. if the label is Centered horizontally and vertically over its anchor. indicating the distance (in points) the label is offset from its anchor location. LABEL_INFO_OFFSET LABEL_INFO_POSITION For example. All rights reserved. which is an approximation of the label. LABEL_INFO_ROWID Integer value. 343 . Integer value between 0 and 8. i_layernum As Integer Dim obj_mytext As Object ' Here. Logical value. Dim b_morelabels As Logical Dim i_mapid. LAYER_INFO_LBL_POS_BL (6).Labelinfo( ) function attribute code LABEL_INFO_OBJECT Labelinfo( ) Return Value Text object is returned. using the Labelinfo( ) function to query each label. The return value will match one of these codes: • • • • • • • • • LAYER_INFO_LBL_POS_CC (0). LAYER_INFO_LBL_POS_BR (8). Integer value between 0 and 200. indicating the label's position relative to its anchor location. which you can save in a permanent table. its position is zero. returns zero if no label exists. if the label is Below and to the Right of the anchor. representing the ID number of the row that owns this label. LAYER_INFO_LBL_POS_BC (7). you would assign a Map window's ID to i_mapid. LAYER_INFO_LBL_POS_CR (5). LAYER_INFO_LBL_POS_CL (4). b_morelabels = LabelFindFirst(i_mapid. This feature allows you to convert a label into a text object. i_layernum. LAYER_INFO_LBL_POS_TC (2).

LayerInfo( ) function obj_mytext = LabelInfo(i_mapid. 1 for the top layer). and so on). thematic map layers. see table below. Description The LayerInfo( ) function returns information about one layer in an existing Map window. Syntax LayerInfo( map_window_id. LABEL_INFO_OBJECT) ' At this point. i_layernum) Loop See Also LabelFindByID( ) function. The layer_number must be a valid layer (0 is the cosmetic layer. b_morelabels = LabelFindNext(i_mapid. Return Value Return value depends on attribute parameter. attribute is a code indicating the type of information to return. LabelFindFirst( ) function. See example below. attribute ) map_window_id is a Map window identifier. call the MapperInfo( ) function. From here you can also query the Hotlink options using the LAYER_HOTLINK_* attributes. to determine the number of layers in a Map window. LabelFindNext( ) function LayerInfo( ) function Purpose Returns information about a layer in a Map window.DEF. you could save the obj_mytext object ' in a permanent table. codes are defined in MAPBASIC. 1 is the topmost table layer. and map layers representing raster image tables). layer_number is the number of a layer in the current Map window (for example. i_layernum.5 . layer_number. MapBasic 8. The attribute parameter must be one of the codes from the following table. or you could query it by ' calling ObjectInfo( ) or ObjectGeography( ). Restrictions Many of the settings that you can query using LayerInfo( ) function only apply to conventional map layers (as opposed to Cosmetic map layers. All rights reserved. 344 © 2006 MapInfo Corporation.

Logical. TRUE if the layer is selectable. LAYER_INFO_EDITABLE LAYER_INFO_LBL_ PARTIALSEGS LAYER_INFO_SELECTABLE LAYER_INFO_PATH LAYER_INFO_ZOOM_LAYERED LAYER_INFO_ZOOM_MIN LAYER_INFO_ZOOM_MAX LAYER_INFO_COSMETIC LAYER_INFO_DISPLAY • • LAYER_INFO_OVR_LINE LAYER_INFO_OVR_PEN LAYER_INFO_OVR_BRUSH LAYER_INFO_OVR_SYMBOL Pen style used for displaying linear objects. 345 . this table name can be used with other statements (for example. LAYER_INFO_DISPLAY_GLOBAL (objects in this layer are displayed with a “style override” specified in Layer Control).) Float value. TRUE if this is the Cosmetic layer. (To set MapBasic's distance units. LAYER_INFO_DISPLAY_VALUE (objects in this layer appear as thematic shading). Float value. TRUE if the Label Partial Objects check box is selected for this layer. SmallInt. String value representing the full directory path of the table associated with the map layer. indicating the minimum zoom value (in MapBasic's current distance units) at which the layer displays. TRUE if zoom-layering is enabled. Select statement). Logical value. Brush style used for displaying filled objects. Reference Guide © 2006 MapInfo Corporation. Logical value. Pen style used for displaying the borders of filled objects. LAYER_INFO_DISPLAY_GRAPHIC (objects in this layer appear in their “default” style—the style saved in the table). Logical. indicating how and whether this layer is displayed.LayerInfo( ) function attribute code LAYER_INFO_NAME LayerInfo( ) Return Value String indicating the name of the table associated with this map layer. If the specified layer is the map's Cosmetic layer. the string will be a table name such as “Cosmetic1”. TRUE if the layer is editable. Symbol style used for displaying point objects. All rights reserved. return value will be one of these values: • • LAYER_INFO_DISPLAY_OFF (the layer is not displayed). indicating the maximum zoom value at which the layer displays. use Set Distance Units statement. Logical value.

x. All rights reserved. For applications compiled with MapBasic 3. String value: the expression used in labels. R=Right.0 or later. L=Left): • • • • • • • • • LAYER_INFO_LBL_POS_TL LAYER_INFO_LBL_POS_TC LAYER_INFO_LBL_POS_TR LAYER_INFO_LBL_POS_CL LAYER_INFO_LBL_POS_CC LAYER_INFO_LBL_POS_CR LAYER_INFO_LBL_POS_BL LAYER_INFO_LBL_POS_BC LAYER_INFO_LBL_POS_BR LAYER_INFO_LBL_VISIBILITY SmallInt value. C=Center. this query always returns FALSE. connects a label to its original location after you move the label. this query returns the following values: Logical value: TRUE if layer is set to use the current font. SmallInt value indicating what type of line. SmallInt value. The return value will match one of these values: • • • LAYER_INFO_LBL_LT_NONE (no line) LAYER_INFO_LBL_LT_SIMPLE (simple line) LAYER_INFO_LBL_LT_ARROW (line with an arrowhead) LAYER_INFO_LBL_PARALLEL LAYER_INFO_LBL_POS Logical value: TRUE if layer is set for parallel labels. indicating whether labels are visible. if any. MapBasic 8. For applications compiled with MapBasic 4.5 .LayerInfo( ) function attribute code LAYER_INFO_OVR_FONT LAYER_INFO_LBL_CURFONT LayerInfo( ) Return Value Font style used for displaying text objects. LAYER_INFO_LBL_FONT LAYER_INFO_LBL_EXPR LAYER_INFO_LBL_LT Font style used in labels. or FALSE if layer is set to use the custom font (see LAYER_INFO_LBL_FONT). B=Bottom. indicating label position. Return value will match one of these values (T=Top. Return value will be one of these values: • • • LAYER_INFO_LBL_VIS_ON (labels always visible) LAYER_INFO_LBL_VIS_OFF (labels never visible) LAYER_INFO_LBL_VIS_ZOOM (labels visible when in zoom range) 346 © 2006 MapInfo Corporation. see the Visibility clause of the Set Map statement on page 585.

Logical value. Logical value.483. in points. String value representing the full directory path of the table associated with the map layer. Integer value. Logical value. TRUE if layer displays object nodes. See the Auto clause of the Set Map statement on page 585. All rights reserved. SmallInt value. TRUE if the Label Partial Segments check box is checked for this layer. indicating the maximum number of labels allowed for this layer. TRUE if layer displays direction arrows on linear objects. Float value.647. LAYER_INFO_TYPE_IMAGE for a raster image layer LAYER_INFO_TYPE_THEMATIC for a thematic layer LAYER_INFO_TYPE_GRID for a grid image layer LAYER_INFO_TYPE_WMS for a layer from a Web Service Map LAYER_INFO_LBL_ZOOM_MAX LAYER_INFO_LBL_ AUTODISPLAY LAYER_INFO_LBL_OVERLAP LAYER_INFO_LBL_DUPLICATES LAYER_INFO_LBL_OFFSET LAYER_INFO_LBL_MAX LAYER_INFO_LBL_ PARTIALSEGS LAYER_INFO_ARROWS LAYER_INFO_NODES LAYER_INFO_CENTROIDS LAYER_INFO_SELECTABLE LAYER_INFO_PATH LAYER_INFO_TYPE LAYER_HOTLINK_EXPR Returns the layer's Hotlink filename expression. indicating the maximum zoom distance for this layer's labels. indicating this layer's file type: • • • • • • LAYER_INFO_TYPE_NORMAL for a normal layer LAYER_INFO_TYPE_COSMETIC for the Cosmetic layer. TRUE if duplicate labels are allowed. SmallInt value from 0 to 50. If no maximum has been set.LayerInfo( ) function attribute code LAYER_INFO_LBL_ZOOM_MIN LayerInfo( ) Return Value Float value. Reference Guide © 2006 MapInfo Corporation. Logical value. TRUE if the layer is selectable. Logical value. The offset value represents a distance. return value is 2. Logical value. Logical value. 347 .147. indicating how far the labels are offset from object centroids. TRUE if overlapping labels are allowed. Logical value: TRUE if this layer is set to display labels automatically. indicating the minimum zoom distance for this layer's labels. TRUE if layer displays object centroids.

To determine whether a map layer is a conventional layer. Syntax Layout [ Position ( x. y specifies the position of the upper left corner of the Layout. use the LAYER_INFO_TYPE setting.Layout statement attribute code LAYER_HOTLINK_MODE LayerInfo( ) Return Value Returns the layer's Hotlink mode. All rights reserved. y ) [ Units paperunits ] ] [ Width window_width [ Units paperunits ] ] [ Height window_height [ Units paperunits ] ] [ { Min | Max } ] paperunits is a string representing the name of a paper unit (for example. MapBasic 8. then this is a "normal" layer ' End If See Also MapperInfo( ) function. “in” or “mm”).5 . Set Map statement Layout statement Purpose Opens a new layout window. 348 © 2006 MapInfo Corporation. one of the following predefined values: • • • LAYER_HOTLINK_RELATIVE HOTLINK_MODE_LABEL HOTLINK_MODE_OBJ HOTLINK_MODE_BOTH Returns TRUE if the relative path option is on. as shown below: i_lay_type = LayerInfo( map_id.. where 0.. LAYER_INFO_TYPE) If i_lay_type = LAYER_INFO_TYPE_NORMAL Then ' ' . thematic map layers.0 represents the upper-left corner of the MapInfo Professional window. and map layers representing raster image tables). x. layer_number. Example Many of the settings that you can query using LayerInfo( ) only apply to conventional map layers (as opposed to cosmetic map layers. FALSE otherwise. in paper units.

0) Width 2 Height 4 See Also Open Window statement. See Set Layout statement on page 580 for more information on setting the number of pages in a Layout. If the statement includes the optional Min keyword. Syntax LCase$( string_expr ) string_expr is a string expression. the next Layout window that is opened has the table name Layout2. Set Layout statement LCase$( ) function Purpose Returns a lower-case equivalent of a string. All rights reserved. not the size of the page layout itself. 349 . A MapBasic program can create. Layout Position (0. Description The Layout statement opens a new Layout window. If the statement includes the optional Max keyword. etc. located at the upper-left corner of the MapInfo Professional workspace. Return Value String Reference Guide © 2006 MapInfo Corporation. select. The page layout size is controlled by the paper size currently in use and the number of pages included in the Layout. MapInfo Professional assigns a special hidden table name to each Layout window. the window is minimized before it is displayed. The first Layout window opened has the table name Layout1. For example. or modify objects on a Layout window by issuing statements which refer to these table names. The Width and Height clauses control the size of the Layout window. in Paper units. the window appears maximized. the following statement selects all objects from a Layout window: Select * From Layout1 Example The following example creates a Layout window two inches wide by four inches high. filling all of MapInfo Professional 's screen space.LCase$( ) function window_width and window_height dictate the size of the window.

Left$( ) returns a null string. the function call: LCase$( "A#12a" ) returns the string value “a#12a”. num_expr is a numeric expression. num_expr ) string_expr is a string expression. lower_case contains the value "los angeles" ' See Also Proper$( ) function. Thus. Syntax Left$( string_expr. Example Dim regular. zero or larger. UCase$( ) function Left$( ) function Purpose Returns part or all of a string. MapBasic 8. and punctuation marks are not affected. lower_case As String regular = "Los Angeles" lower_case = LCase$(regular) ' ' Now. 350 © 2006 MapInfo Corporation. zero or larger. All rights reserved.to lower-case only affects alphabetic characters (A through Z). The num_expr parameter should be an integer value. If num_expr is zero. numeric digits. If num_expr has a fractional value. beginning at the left end of the string.Left$( ) function Description The LCase$( ) function returns the string which is the lower-case equivalent of the string expression string_expr.5 . Conversion from upper. If the num_expr parameter is larger than the number of characters in the string_expr string. Left$( ) returns a copy of the entire string_expr string. Return Value String Description The Left$( ) function returns a string which consists of the leftmost num_expr characters of the string expression string_expr. MapBasic rounds to the nearest integer.

Right$( ) function LegendFrameInfo( ) function Purpose Returns information about a frame within a legend. Attribute codes FRAME_INFO_TYPE LegendFrameInfo( ) Return Value Returns one of the following predefined constant indicating frame type: • • FRAME_TYPE_STYLE FRAME_TYPE_THEME FRAME_INFO_MAP_LAYER_ID FRAME_INFO_REFRESHABLE Returns the ID of the layer to which the frame corresponds. FRAME_INFO_POS_X FRAME_INFO_POS_Y Reference Guide © 2006 MapInfo Corporation. All rights reserved.LegendFrameInfo( ) function Example Dim whole. Syntax LegendFrameInfo( window_id. Return Value Depends on the attribute parameter. frame_id is a number that specifies which frame within the legend window you want to query. attribute is an integer code indicating which type of information to return. partial As String whole = "Afghanistan" partial = Left$(whole. attribute ) window_id is a number that specifies which legend window you want to query. partial contains the string: "Afghan" See Also Mid$( ) function. Always returns TRUE for theme frames. 6) ' at this point. Returns the distance of the frame's upper left corner from the top edge of the legend canvas (in paper units). Frames are numbered 1 to n where n is the number of frames in the legend. 351 . frame_id. Returns the distance of the frame’s upper left corner from the left edge of the legend canvas (in paper units). Returns TRUE if the frame was created without the Norefresh keyword.

352 © 2006 MapInfo Corporation. Returns TRUE if the frame is visible (theme frames can be invisible). MapBasic 8. Returns an empty string for a theme frame. Returns the title of a style frame or theme frame. attribute is an integer code indicating which type of information to return. Returns the subtitle of a style frame or theme frame. Returns the legend attribute column name as a string if there is one. Returns the pen used to draw the border. Returns the label expression as a string if there is one. All rights reserved. Return Value Depends on the attribute parameter. Syntax LegendInfo( window_id.5 . FRAME_INFO_SUBTITLE FRAME_INFO_SUBTITLE_FONT FRAME_INFO_BORDER_PEN FRAME_INFO_NUM_STYLES FRAME_INFO_VISIBLE FRAME_INFO_COLUMN FRAME_INFO_LABEL LegendInfo( ) function Purpose Returns information about a legend.LegendInfo( ) function Attribute codes FRAME_INFO_WIDTH FRAME_INFO_HEIGHT FRAME_INFO_TITLE FRAME_INFO_TITLE_FONT LegendFrameInfo( ) Return Value Returns the width of the frame (in paper units). Zero if theme frame. attribute ) window_id is a number that specifies which legend window you want to query. Returns the font of a style frame title. Returns the default title font if the frame has no title or if it is a theme frame. Returns the height of the frame (in paper units). Returns an empty string for a theme frame. Returns the number of styles in a frame. Same as FRAME_INFO_TITLE_FONT.

frame_id. Reference Guide © 2006 MapInfo Corporation. attribute ) window_id is a number that specifies which legend window you want to query. Returns predefined value to indicate the layout of the legend: • • • ORIENTATION_PORTRAIT ORIENTATION_LANDSCAPE ORIENTATION_CUSTOM LEGEND_INFO_ORIENTATION LEGEND_INFO_NUM_FRAMES LEGEND_INFO_STYLE_SAMPLE_SIZE Returns the number of frames in the legend. frame_id is a number that specifies which frame within the legend window you want to query. Frames are numbered 1 to n where n is the number of frames in the legend. Returns 0 for small legend sample size style or 1 for large legend sample size style. attribute is an integer code indicating which type of information to return. Syntax LegendStyleInfo( window_id.LegendStyleInfo( ) function Attribute Code LEGEND_INFO_MAP_ID LegendInfo( ) Return Value Returns the ID of the parent map window (can also get this value by calling the WindowInfo( ) function with the WIN_INFO_TABLE code). style_id. 353 . Styles are numbered 1 to n where n is the number of styles in the frame. style_id is a number that specifies which style within a frame you want to query. Example LegendInfo(FrontWindow( ) LEGEND_INFO_STYLE_SAMPLE_SIZE) See Also: LegendStyleInfo( ) function LegendStyleInfo( ) function Purpose Returns information about a style item within a legend frame. All rights reserved.

Error Conditions Generates an error when issued on a frame that has no styles (theme frame). the Len( ) function returns the number of characters in the string. Len( ) returns the size of the variable. All rights reserved. if you pass an integer variable. MapBasic 8. Thus. while if you pass a SmallInt variable. expr cannot be a Pen.5 . Len( ) will return the value 2 (because each SmallInt variable occupies 2 bytes). Otherwise. in bytes. if expr is a MapBasic variable. Symbol. Example Dim name_length As SmallInt name_length = Len("Boswell") ' name_length now has the value: 7 354 © 2006 MapInfo Corporation. Font. Brush. Returns the object of the style. Len( ) will return the value 4 (because each integer variable occupies 4 bytes). Syntax Len( expr ) expr is a variable expression. If the expr expression represents a character string. Returns the font of the style. See Also LegendInfo( ) function Len( ) function Purpose Returns the number of characters in a string or the number of bytes in a variable.Len( ) function Return Value Attribute Code LEGEND_STYLE_INFO_TEXT LEGEND_STYLE_INFO_FONT LEGEND_STYLE_INFO_OBJ LegendStyleInfo( ) Return Values Returns the text of the style. Return Value SmallInt Description The behavior of the Len( ) function depends on the data type of the expr parameter. or Alias.

as shown in the table below. 355 . "\_%". The pattern_string parameter can contain the following wildcard characters: _ (underscore) % (percent) matches a single character. "") Like( string_var. "\") Reference Guide © 2006 MapInfo Corporation. "%America".Like( ) function See Also ObjectLen( ) function Like( ) function Purpose Returns TRUE or FALSE to indicate whether a string satisfies pattern-matching criteria. to perform a comparison that is case-insensitive. "South%". "%ing%". use an empty string (""). Return Value Logical value (TRUE if string matches pattern_string). To search for instances of the underscore or percent characters. Use an escape character (for example. To determine if a string… starts with “South” ends with “America” contains “ing” at any point starts with an underscore Specify these parameters: Like( string_var. escape_char is a string expression defining an escape character. "") Like( string_var. specify an escape_char parameter. “\”) if you need to test for the presence of one of the wild-card characters (“%” and “_”) in the string expression. pattern_string. This string comparison is case-sensitive. "" ) Like( string_var. use the Like operator. pattern_string is a string that contains regular characters or special wild-card characters. If no escape character is desired. Syntax Like( string. matches zero or more characters. All rights reserved. escape_char ) string is a string expression to test. Description The Like( ) function performs string pattern-matching.

Print # statement 356 © 2006 MapInfo Corporation. StringCompare( ) function Line Input statement Purpose Reads a line from a sequential text file into a variable. The Line Input statement treats each line of the file as one long string. indicating the number of an open file.txt" For Input As #1 Open File "copy. use the Input # statement instead of Line Input. and you want to read each expression into a separate variable. Open File statement.txt" For Output As #2 Do While Not EOF(1) Line Input #1. Example The following program opens an existing text file. If each line of a file contains a comma-separated list of expressions. str End If Loop Close File #1 Close File #2 See Also Input # statement. The text file must already be open. var_name is the name of a string variable. and stores the results in a string variable. and copies the contents of the file to a separate text file. Description The Line Input statement reads an entire line from a text file. All rights reserved. Syntax Line Input [#] filenum.Line Input statement See Also Len( ) function. MapBasic 8. reads the contents of the text file one line at a time. str If Not EOF(1) Then Print #2. in Input mode. var_name filenum is an integer value.5 . Dim str As String Open File "original.

357 .xml).LocateFile$( ) function LocateFile$( ) function Purpose Return the path to one of the MapInfo application data files. Default workspace file (mapinfow.fnt). Color file (mapinfow. Pen file (mapinfow. XML list of geocode servers (MIGeocodeServers. Custom symbol directory (custsymb). Projection file (mapinfow. Menu file (mapinfow. Return Value String Reference Guide © 2006 MapInfo Corporation. XML list of routing servers (MIRoutingServers. Syntax LocateFile$( file_id ) file_id is one of the following values Value LOCATE_PREF_FILE LOCATE_DEF_WOR LOCATE_CLR_FILE LOCATE_PEN_FILE LOCATE_FNT_FILE LOCATE_ABB_FILE LOCATE_PRJ_FILE LOCATE_MNU_FILE LOCATE_CUSTSYMB_DIR LOCATE_THMTMPLT_DIR LOCATE_GRAPH_DIR LOCATE_WMS_SERVERLIST LOCATE_WFS_SERVERLIST LOCATE_GEOCODE_SERVERLIST LOCATE_ROUTING_SERVERLIST Description Preference file (mapinfow. Symbol file (mapinfow.wor).xml).xml). Abbreviation file (mapinfow.abb).mnu).pen).prf).xml). Graph support directory (GraphSupport).prj). All rights reserved.clr). Theme template directory (thmtmpl). XML list of WFS servers (MIWFSServers. XML list of WMS servers (MIWMSServers.

these files where. Example include "mapbasic. including the program directory. this function returns the location where MapInfo Professional found that file. instead LocateFile$( ) should be used to determine the actual location. In versions prior to 6. this is the same number specified in the As clause of the Open File statement. All rights reserved.exe). MapInfo Professional installs these files under the user's Application Data directory. but there are several valid locations for these files. MapBasic 8. for the most part.LOF( ) function Description Given the ID of a MapInfo application data file.5. Syntax LOF( filenum ) filenum is the number of an open file. The file parameter represents the number of an open file. As of 6. MapBasic applications should not assume the location of these files. Error Conditions ERR_FILEMGR_NOTOPEN error generated if the specified file is not open.def" declare sub main sub main dim sGraphLocations as string sGraphLocations = LocateFile$(LOCATE_GRAPH_DIR) Print sGraphLocations end sub See Also GetFolderPath$( ) function LOF( ) function Purpose Returns the length of an open file. Return Value Integer Description The LOF( ) function returns the length of an open file. in bytes.5 .5. 358 © 2006 MapInfo Corporation. installed into the program directory (same directory as mapinfow.

divide the natural log of n ( Log( n ) ) by the natural logarithm of 10 ( Log( 10 ) ). accordingly.7182818 (approximately) Reference Guide © 2006 MapInfo Corporation. log_val As Float original_val = 2. 359 . Return Value Float Description The Log( ) function returns the natural logarithm of the numeric expression specified by the num_ expr parameter.7182818 log_val = Log(original_val) ' log_val will now have a value of 1 (approximately). the Log( ) function will generate an error if num_expr has a negative value. To obtain the base-10 logarithm of the number n. You can calculate logarithmic values in other bases (for example. Example Dim original_val. ' since E raised to the power of 1 equals ' 2. The logarithm is only defined for positive numbers.7182818. Syntax Log( num_expr ) num_expr is a numeric expression.Log( ) function Example Dim size As Integer Open File "import. All rights reserved. The natural logarithm represents the number to which the mathematical value e must be raised in order to obtain num_expr. base 10) using the natural logarithm. e has a value of approximately 2.txt" For Binary As #1 size = LOF(1) ' size now contains the # of bytes in the file See Also Open File statement Log( ) function Purpose Returns the natural logarithm of a number.

360 © 2006 MapInfo Corporation. Example Dim name As String name = " Mary Smith" name = LTrim$(name) ' name now contains the string "Mary Smith" See Also RTrim$( ) function Main procedure Purpose The first procedure called when an application is run. Syntax LTrim$( string_expr ) string_expr is a string expression.LTrim$( ) function See Also Exp( ) function LTrim$( ) function Purpose Trims space characters from the beginning of a string and returns the results. All rights reserved. Return Value String Description The LTrim$( ) function removes any spaces from the beginning of the string_expr string. MapBasic 8. and returns the resultant string. Syntax Declare Sub Main Sub Main statement_list End Sub statement_list is a list of statements to execute when an application is run.5 .

The Main procedure calls the Talk procedure through the Call statement.. the following example explicitly declares the Main procedure. Declare Sub Talk(ByVal msg As String) Call Talk("Hello") Call Talk("Goodbye") Sub Talk(ByVal msg As String) Note msg End Sub The next example contains an explicit Main procedure. Declare Sub Main Sub Main Note "Testing. If an application contains a sub procedure called Main. you are not required to explicitly declare the Main procedure. MapInfo Professional runs that procedure automatically when the application is first run. MapBasic will execute the Note statement. producing the same results (i. Declare Sub Main Declare Sub Talk(ByVal msg As String) Sub Main Call Talk("Hello") Call Talk("Goodbye") End Sub Reference Guide © 2006 MapInfo Corporation.e. MapBasic considers that program to be in an implicit Main procedure. However. Instead of declaring a procedure named Main. a Note statement). Alternately. 361 . All rights reserved. For example. MapBasic will then treat that group of statements as if they were in a Main procedure." End Sub The next example contains an implicit Main procedure. The implicit Main procedure calls the Talk procedure through the Call statement. outside of any procedure declaration.Main procedure Description Main is a special-purpose MapBasic procedure name. issuing Call statements) to cause other sub procedures to be executed. Example A MapBasic program can be as short as a single line. When you run that application. you could create a MapBasic program consisting only of the following statement: Note "Testing. you can simply place one or more statements at or near the top of your program file." If the statement above comprises your entire program. and a separate sub procedure called Talk. one two three. The Main procedure can then take actions (for example. one two three. This is known as an “implicit” Main procedure (as opposed to an “explicit” Main procedure). and a separate sub procedure called Talk.

MakeBrush( ) function Sub Talk(ByVal msg As String) Note msg End Sub See Also EndHandler procedure. StyleAttr( ) function 362 © 2006 MapInfo Corporation. CYAN. See Brush clause on page 109 for more information about Brush settings. Set Style. Sub…End Sub statement. MapBasic 8. Syntax MakeBrush( pattern. ToolHandler procedure. All rights reserved.5 . specify -1 as the background color. WinClosedHandler procedure MakeBrush( ) function Purpose Returns a Brush value. See Brush clause on page 109 for a listing of the patterns. backcolor is the integer RGB color value of the background of the pattern. forecolor. Example Include "mapbasic. dictating a fill pattern. SelChangedHandler procedure.def" Dim b_water As Brush b_water = MakeBrush(64. backcolor) pattern is an integer value from 1 to 8 or from 12 to 71. and specify a pattern of 3 or greater. forecolor is the integer RGB color value of the foreground of the pattern. Set Map. Return Value Brush Description The MakeBrush( ) function returns a Brush value. or may be used as a parameter within a statement that takes a Brush setting as a parameter (such as Create Ellipse. RGB( ) function. The return value can be assigned to a Brush variable. CurrentBrush( ) function. See RGB( ) function on page 483 for details. or Shade). BLUE) See Also Brush clause. RemoteMsgHandler procedure. To make the background transparent.

1 2 3 4 5 7 Reference Guide © 2006 MapInfo Corporation. size is an integer point size. See table below. size. The Show Background. The following table describes how the customstyle argument controls the symbol's style: customstyle value 0 Symbol Style The Show Background. The file must be in the CustSymb directory inside the user's MapInfo directory. customstyle is an integer code controlling color and background attributes.MakeCustomSymbol( ) function MakeCustomSymbol( ) function Purpose Returns a Symbol value based on a bitmap file. Syntax MakeCustomSymbol( filename. The Apply Color setting is on. color is an integer RGB color value. White pixels in the bitmap are displayed as transparent. Return Value Symbol Description The MakeCustomSymbol( ) function returns a Symbol value based on a bitmap file. and the Display at Actual Size settings are off. the Apply Color. allowing whatever is behind the symbol to show through. see RGB( ) function on page 483 for details. The Display at Actual Size setting is on. the bitmap image is rendered at its native width and height in pixels. The Show Background setting is on. the symbol appears in its default state at the point size specified by the size parameter. the Apply Color. 363 . customstyle ) filename is a string up to 31 characters long. Both Show Background and Apply Color are on. See Symbol clause on page 651 for information about other symbol types. All rights reserved. color. from 1 to 48. and the Display at Actual Size settings are on. non-white pixels in the bitmap are replaced with the symbol's color setting. representing the name of a bitmap file. white pixels in the bitmap are opaque. The Show Background and Display at Actual Size settings are on.

5 . style.WHITE) See Also CurrentFont( ) function. Return Value Font Description The MakeFont( ) function returns a Font value. MakeSymbol( ) function. BLUE. Font clause. The return value can be assigned to a Font variable. size. StyleAttr( ) function 364 © 2006 MapInfo Corporation. See Font clause on page 295 for more information about Font settings.def" Dim sym_marker As Symbol sym_marker = MakeCustomSymbol("CAR1-64. 18. forecolor is the RGB color value for the text. 1. one or greater.BLACK. size is an integer point size. 0) See Also CurrentSymbol( ) function. 20. if the style setting specifies a halo). To make the background transparent. backcolor is the RGB color value for the background (or the halo color. specify -1 as the background color. See Font clause for details. This argument is case sensitive. forecolor. MakeFontSymbol( ) function. See RGB( ) function on page 483. 1 = bold text.BMP". “Helv”). MapBasic 8.MakeFont( ) function Example Include "mapbasic. etc. Syntax MakeFont( fontname.def" Dim big_title As Font big_title = MakeFont("Helvetica". or may be used as a parameter within a statement that takes a Font setting as a parameter (such as Create Text statement or Set Style statement). 0 = plain text. StyleAttr( ) function. All rights reserved. backcolor ) fontname is a text string specifying a font (for example. style is a positive integer expression. Symbol clause MakeFont( ) function Purpose Returns a Font value. Example Include "mapbasic.

rotation ) shape is a SmallInt value. See Symbol clause on page 651 for information about other symbol types. Reference Guide © 2006 MapInfo Corporation. to specify both the Bold and the Drop Shadow attributes. fontname. specifying a character code from a TrueType font. outline. rotation is a floating-point number indicating the symbol's rotation angle. in degrees. see below. color.MakeFontSymbol( ) function MakeFontSymbol( ) function Purpose Returns a Symbol value. size. add the values from the left column. Border and Halo are mutually exclusive. 365 . size is a SmallInt value from 1 to 48. using a character from a TrueType font as the symbol. 31 or larger (31 is invisible). fontstyle. Syntax MakeFontSymbol( shape. For example. All rights reserved. Return Value Symbol Description The MakeFontSymbol( ) function returns a Symbol value based on a character in a TrueType font. use a fontstyle value of 33. and other attributes. fontstyle is a numeric code controlling bold. The following table describes how the fontstyle parameter controls the symbol's style: fontstyle value 0 1 16 32 256 Plain Bold Symbol Style Border (black outline) Drop Shadow Halo (white outline) To specify two or more style attributes. fontname is a string representing the name of a TrueType font (for example. This argument is case sensitive. dictating the point size of the symbol. color is an integer RGB color value. “WingDings”). see RGB( ) function on page 483 for details.

pattern. Example Include "mapbasic.24.RED. color) width specifies a pen width. Set Style statement.def" Dim sym_marker As Symbol sym_marker = MakeFontSymbol(65. See Pen clause on page 446 for more information about Pen settings. Return Value Pen Description The MakePen( ) function returns a Pen value. Syntax MakePen( width. MakeSymbol( ) function.def" Dim p_bus_route As Pen p_bus_route = MakePen(3.MakePen( ) function Example Include "mapbasic. or may be used as a parameter within a statement that takes a Pen setting as a parameter (such as Create Line statement. which defines a line style. see RGB( ) function on page 483 for details. see Pen clause for a listing. pattern specifies a line pattern. color is the RGB color value. All rights reserved. or Set Map statement). RGB( ) function 366 © 2006 MapInfo Corporation. StyleAttr( ) function. MakeCustomSymbol( ) function. Pen clause. Create Pline statement.5 . 9. MapBasic 8.32. Symbol clause MakePen( ) function Purpose Returns a Pen value. RED) See Also CurrentPen( ) function.0) See Also CurrentSymbol( ) function. The return value can be assigned to a Pen variable."WingDings". StyleAttr( ) function.

367 .0 symbol set. The MapInfo 3. or Shade statement). specifying a symbol shape. StyleAttr( ) function. color is an integer RGB color value.def" Dim sym_marker As Symbol sym_marker = MakeSymbol(44.MakeSymbol( ) function MakeSymbol( ) function Purpose Returns a Symbol value. Syntax MakeSymbol( shape. dictating the point size of the symbol. size ) shape is a SmallInt value. call the MakeCustomSymbol( ) function. Set Map statement. call the MakeFontSymbol( ) function. size is a SmallInt value from 1 to 48. All rights reserved. Return Value Symbol Description The MakeSymbol( ) function returns a Symbol value. To create a symbol from a character in a TrueType font. MakeFontSymbol( ) function. using a character from the MapInfo 3. standard symbol set provides symbols 31 through 67. To create a symbol from a bitmap file. MakeCustomSymbol( ) function. See Symbol clause on page 651 for more information about Symbol settings. color. 31 or larger (31 is invisible).0 and has been maintained in subsequent versions of MapInfo Professional. Example Include "mapbasic. see RGB( ) function on page 483 for details. RED. or may be used as a parameter within a statement that takes a Symbol clause as a parameter (such as Create Point statement. Symbol clause Reference Guide © 2006 MapInfo Corporation. 16) See Also CurrentSymbol( ) function. The return value can be assigned to a Symbol variable.0 symbol set is the symbol set that was originally published with MapInfo for Windows 3. see Symbol clause on page 651 for a listing. Set Style statement.

The default size of the resultant Map window is roughly a quarter of the screen size. The table does not need to actually contain any graphical objects. the Map statement can specify multiple table names (separated by commas) to open a multi-layer Map window. 368 © 2006 MapInfo Corporation.5 . the window is minimized immediately. x. if the Map statement includes the Min keyword. thus. Syntax Map From table [ . Optionally. All rights reserved. and Width clauses allow you to control the size and position of the new Map window. Note that the Position clause specifies a position relative to the upper left corner of the MapInfo application. not relative to the upper left corner of the screen. since any Map window must contain at least one layer. y specifies the position of the upper left corner of the Map window. After you open a Map window. The Height and Width clauses dictate the window size. Optional Position. taking up all of the screen space available to MapInfo Professional. Description The Map statement opens a new Map window. y ) [ Units paperunits ] ] [ Width window_width [ Units paperunits ] ] [ Height window_height [ Units paperunits ] ] [ { Min | Max } ] table is the name of an open table. the table must be able to have graphic objects associated with the records. window_width and window_height specify the size of the Map window. The first table name in the Map statement will be drawn last whenever the Map window is redrawn. but the structure of the table must specify that objects may be attached. “in”). The table name specified must already be open. Typically. and tables with region (boundary) objects appear later in Map statements. MapBasic 8. you can modify the window by issuing Set Map statements. in paper units. The table must also be mappable. the new Map window is maximized. in inches. ] [ Position ( x. If the Map statement includes the optional Max keyword. paperunits is the name of a paper unit (for example. The Map statement must specify at least one table. the first table in the Map statement will always appear on top.Map statement Map statement Purpose Opens a new Map window. table . Conversely. Height.. the default position of the window depends on how many windows are currently on the screen.. in other words. in paper units. tables with point objects appear earlier in Map statements.

world Position (1. The attribute parameter should be one of the codes from the following table. Reference Guide © 2006 MapInfo Corporation. depending on the attribute parameter. A MapBasic program can change the projection by issuing a Set Map statement. Set Shade statement. codes are defined in MAPBASIC. Open Table "world" Open Table "cust1994" As customers Map from customers. inset one inch from the upper left corner of the MapInfo application. logical. Description The Map3DInfo( ) function returns information about a 3DMap window. attribute is an integer code.1) Width 3 Height 2 See Also Add Map statement. There are several numeric attributes that Map3DInfo( ) can return about any given 3DMap window. 369 . attribute ) window_id is an integer window identifier. Example The following example opens a Map window three inches wide by two inches high.Map3DInfo( ) function Each Map window can have its own projection. The window_id parameter specifies which 3DMap window to query. or call the WindowID( ) function at any time after the window's creation. All rights reserved. Return Value Float. The attribute parameter tells the Map3DInfo( ) function which Map window statistic to return. Syntax Map3DInfo( window_id. call the FrontWindow( ) function immediately after opening a window. To obtain a window identifier. Set Map statement. A user can change a map's projection by choosing the Map > Options command. Remove Map statement. MapInfo Professional decides a Map window's initial projection based on the native projection of the first table mapped. or string. indicating which type of information should be returned. The map has two layers.DEF. Shade statement Map3DInfo( ) function Purpose Returns properties of a 3DMap window.

Float result representing the first value of the ViewUp Unit Normal Vector.5 . Float result representing the x-coordinate of the Camera in the scene. Integer result representing the background color. for example. Float result representing the x-coordinate of the Cameras FocalPoint in the scene. Integer result representing the X resolution of the grid(s) in the 3DMap window. Float result representing the z-coordinate of the Cameras FocalPoint in the scene.Map3DInfo( ) function Attribute MAP3D_INFO_SCALE MAP3D_INFO_RESOLUTION_X Return Value Float result representing the 3DMaps scale factor. Float result representing the second value of the ViewUp Unit Normal Vector. see the RGB function. Integer result representing the Light color. Integer result representing the Y resolution of the grid(s) in the 3DMap window. Float result representing the y-coordinate of the Cameras FocalPoint in the scene. MAP3D_INFO_RESOLUTION_Y MAP3D_INFO_BACKGROUND MAP3D_INFO_UNITS MAP3D_INFO_LIGHT_X MAP3D_INFO_LIGHT_Y MAP3D_INFO_LIGHT_Z MAP3D_INFO_LIGHT_COLOR MAP3D_INFO_CAMERA_X MAP3D_INFO_CAMERA_Y MAP3D_INFO_CAMERA_Z MAP3D_INFO_CAMERA_FOCAL_X MAP3D_INFO_CAMERA_FOCAL_Y MAP3D_INFO_CAMERA_FOCAL_Z MAP3D_INFO_CAMERA_VU_1 MAP3D_INFO_CAMERA_VU_2 370 © 2006 MapInfo Corporation. “mi” for miles. Float result representing the x-coordinate of the Light in the scene. MapBasic 8. String representing the map's abbreviated area unit name. All rights reserved. see RGB( ) function on page 483. Float result representing the z-coordinate of the Light in the scene. Float result representing the y-coordinate of the Camera in the scene. Float result representing the y-coordinate of the Light in the scene. Float result representing the z-coordinate of the Camera in the scene.

Float result representing the cameras near clipping plane. Float result representing the second value of the ViewPlane Unit Normal Vector. MAP3D_INFO_ LIGHT_Z) Print "MAP3D_INFO_LIGHT_COLOR: " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ LIGHT_COLOR) Print "MAP3D_INFO_CAMERA_X: " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ LIGHT_Y ) Print "MAP3D_INFO_LIGHT_Z: " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ RESOLUTION_X) Print "MAP3D_INFO_RESOLUTION_Y: " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ BACKGROUND) Print "MAP3D_INFO_UNITS: " + Map3DInfo(FrontWindow( ).def" Print "MAP3D_INFO_SCALE: " + Map3DInfo(FrontWindow( ). MAP3D_ Reference Guide © 2006 MapInfo Corporation. MAP3D_INFO_ CAMERA_X) Print "MAP3D_INFO_CAMERA_Y : " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ CAMERA_Z ) Print "MAP3D_INFO_CAMERA_FOCAL_X: " + Map3DInfo(FrontWindow( ). Float result representing the cameras far clipping plane. Float result representing the first value of the ViewPlane Unit Normal Vector. MAP3D_ INFO_CAMERA_FOCAL_X) Print "MAP3D_INFO_CAMERA_FOCAL_Y: " + Map3DInfo(FrontWindow( ). All rights reserved. MAP3D_ INFO_CAMERA_FOCAL_Y) Print "MAP3D_INFO_CAMERA_FOCAL_Z: " + Map3DInfo(FrontWindow( ).Map3DInfo( ) function Attribute MAP3D_INFO_CAMERA_VU_3 Return Value Float result representing the third value of the ViewUp Unit Normal Vector. MAP3D_INFO_ RESOLUTION_Y) Print "MAP3D_INFO_BACKGROUND: " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ CAMERA_Y ) Print "MAP3D_INFO_CAMERA_Z : " + Map3DInfo(FrontWindow( ). MAP3D_INFO_UNITS) Print "MAP3D_INFO_LIGHT_X : " + Map3DInfo(FrontWindow( ). MAP3D_INFO_CAMERA_VPN_1 MAP3D_INFO_CAMERA_VPN_2 MAP3D_INFO_CAMERA_VPN_3 MAP3D_INFO_CAMERA_CLIP_NEAR MAP3D_INFO_CAMERA_CLIP_FAR Example Prints out all the state variables specific to the 3DMap window: include "Mapbasic. MAP3D_INFO_SCALE) Print "MAP3D_INFO_RESOLUTION_X: " + Map3DInfo(FrontWindow( ). Float result representing the third value of the ViewPlane Unit Normal Vector. MAP3D_INFO_ LIGHT_X ) Print "MAP3D_INFO_LIGHT_Y : " + Map3DInfo(FrontWindow( ). 371 .

The window_id parameter specifies which Map window to query. Syntax MapperInfo( window_id. MAP3D_ INFO_CAMERA_CLIP_FAR) See Also Create Map3D statement. To obtain a window identifier. MAP3D_INFO_ CAMERA_VPN_1) Print "MAP3D_INFO_CAMERA_VPN_2: " + Map3DInfo(FrontWindow( ). MAP3D_ INFO_CAMERA_CLIP_NEAR) Print "MAP3D_INFO_CAMERA_CLIP_FAR: " + Map3DInfo(FrontWindow( ). attribute ) window_id is an integer window identifier. The attribute parameter should be one of the codes from the following table. call the FrontWindow( ) function immediately after opening a window. The attribute parameter tells the MapperInfo( ) function which Map window statistic to return. MapBasic 8.DEF. 372 © 2006 MapInfo Corporation. attribute is an integer code.MapperInfo( ) function INFO_CAMERA_FOCAL_Z) Print "MAP3D_INFO_CAMERA_VU_1: " + Map3DInfo(FrontWindow( ). Return Value Float. MAP3D_INFO_ CAMERA_VU_1) Print "MAP3D_INFO_CAMERA_VU_2: " + Map3DInfo(FrontWindow( ). There are several numeric attributes that MapperInfo( ) can return about any given Map window. depending on the attribute parameter.5 . MAP3D_INFO_ CAMERA_VPN_2) Print "MAP3D_INFO_CAMERA_VPN_3: " + Map3DInfo(FrontWindow( ). Set Map3D statement MapperInfo( ) function Purpose Returns coordinate or distance information about a Map window. or string. All rights reserved. MAP3D_INFO_ CAMERA_VU_3) Print "MAP3D_INFO_CAMERA_VPN_1: " + Map3DInfo(FrontWindow( ). MAP3D_INFO_ CAMERA_VPN_3) Print "MAP3D_INFO_CAMERA_CLIP_NEAR: " + Map3DInfo(FrontWindow( ). Description The MapperInfo( ) function returns information about a Map window. See table below for values. codes are defined in MAPBASIC. MAP3D_INFO_ CAMERA_VU_2) Print "MAP3D_INFO_CAMERA_VU_3: " + Map3DInfo(FrontWindow( ). indicating which type of information should be returned. or call the WindowID( ) function at any time after the window's creation. logical.

indicating what aspect of the map is displayed on the status bar. Return value will be one of these: • • • MAPPER_INFO_DISPLAY_SCALE MAPPER_INFO_DISPLAY_ZOOM MAPPER_INFO_DISPLAY_POSITION MAPPER_INFO_COORDSYS_CLAUSE_ WITH_BOUNDS MAPPER_INFO_COORDSYS_NAME MAPPER_INFO_DISPLAY Reference Guide © 2006 MapInfo Corporation. The y-coordinate of the Map window's center. Small integer. The type of clipping being implemented. Returns empty string if CoordSys is not found in MAPINFOW.PRJ. All rights reserved. The x-coordinate of the Map window's center.PRJ (but without the optional “\p…” suffix that appears in MAPINFOW. Returns a string to indicate if a clip region is enabled. it returns the string “off”. String result. indicating the window's CoordSys clause including the bounds. 373 .PRJ). indicating the window's CoordSys clause. String result. Otherwise. Returns the string “on” if a clip region is enabled in the Mapper window. “sq mi” for square miles. Choices include: • • • MAPPER_INFO_CLIP_DISPLAY_ALL MAPPER_INFO_CLIP_DISPLAY_POLYOBJ MAPPER_INFO_CLIP_OVERLAY MAPPER_INFO_CENTERX MAPPER_INFO_CENTERY MAPPER_INFO_CLIP_REGION MAPPER_INFO_CLIP_TYPE MAPPER_INFO_COORDSYS_CLAUSE string result. representing the name of the map's CoordSys as listed in MAPINFOW. for example. Corresponds to Set Map Display.MapperInfo( ) function attribute setting MAPPER_INFO_AREAUNITS MapperInfo( ) Return Value String representing the map's abbreviated area unit name.

“mi” for miles. MAPPER_INFO_EDIT_LAYER MAPPER_INFO_LAYERS MAPPER_INFO_MAXX MAPPER_INFO_MAXY MAPPER_INFO_MERGE_MAP MAPPER_INFO_MINX MAPPER_INFO_MINY MAPPER_INFO_MOVE_DUPLICATE_ NODES 374 © 2006 MapInfo Corporation. Small integer. If the value is 0. To return to using the default from the map preferences. String value: the string of MapBasic statements that a user needs to merge one map window into the current map window. perimeter. any duplicate nodes within the same layer will be moved. A SmallInt indicating the number of the currentlyeditable layer. DMS (degrees. The smallest y-coordinate shown in the window. The largest x-coordinate shown in the window. Corresponds to Set Map Distance Type. for example. length. indicating type of calculation to use for distance. All rights reserved. The smallest x-coordinate shown in the window. call Set Map Move Nodes Default. The largest y-coordinate shown in the window. Returns number of layers in the Map window as a SmallInt (excludes the cosmetic layer). or Military Grid Reference System format. If the value is 1. indicating whether duplicate nodes should be moved when reshaping objects in this Map window. and area calculations for mapper.MapperInfo( ) function attribute setting MAPPER_INFO_DISPLAY_DMS MapperInfo( ) Return Value Small integer.5 . Return values include: • • MAPPER_INFO_DIST_SPHERICAL MAPPER_INFO_DIST CARTESIAN MAPPER_INFO_DISTUNITS String representing the map's abbreviated distance unit name. seconds). duplicate nodes are not moved. A value of zero means that the Cosmetic layer is editable. MapBasic 8. indicating whether the map displays coordinates in decimal degrees. minutes. A value of -1 means that no layer is editable. Return value is one of the following: • • • MAPPER_INFO_DISPLAY_DECIMAL MAPPER_INFO_DISPLAY_DMS MAPPER_INFO_DISPLAY_MGRS (Military Grid Reference System) MAPPER_INFO_DIST_CALC_TYPE Small integer.

A setting for each Map window and providing MapBasic support to set and get the current setting for each mapper. for example.e. Whenever a new Map window is created. All rights reserved. indicating the number of thematic layers in this Map window.Always reproject the map. the initial move duplicate nodes setting will be retrieved from the mapper preference (Options / Preference / Map Window / Move Duplicate Nodes in). which may be different from the coordinate system of the Map window. allow Mapinfo Professional to decide. An existing Map window can be queried for its current Move Duplicate Nodes setting using a new attribute in MapperInfo( ) function. MAPPER_INFO_SCROLLBARS MAPPER_INFO_XYUNITS MAPPER_INFO_ZOOM When you call MapperInfo( ) to obtain coordinate values (for example. the move duplicate nodes can be set to none or move all duplicates within the same layer. Reference Guide © 2006 MapInfo Corporation.. the value returned represents a coordinate in MapBasic's current coordinate system. “degree”.MapperInfo( ) function attribute setting MAPPER_INFO_NUM_THEMATIC MapperInfo( ) Return Value Small integer.Never reproject the map. String value indicating the current value of the reprojection mode. defined in terms of the number of map distance units (for example. String representing the map's abbreviated coordinate unit name. MAPPER_INFO_REPROJECTION MAPPER_INFO_RESAMPLING String value indicating the method for calculating the pixel values of the source image being reprojected. The value can be either: • • CubicConvolution NearestNeighbor MAPPER_INFO_SCALE The Map window's current scale. The value can be either: • • • None .Optimize whether or not to reproject the map. Logical value indicating whether the Map window shows scrollbars. Always . This returns a value in MapBasic's current distance units. the East-West distance currently displayed in the Map window). see Set Distance Units statement on page 570. Miles) per paper unit (for example. by specifying MAPPER_ INFO_CENTERX as the attribute). Auto . The Map window's current zoom value (i. specified in MapBasic's current distance units. Inches) displayed in the window. 375 . During Reshape. Use the Set CoordSys statement to specify a different coordinate system.

These objects will always have their symbology clipped. Label objects are treated similar to Point objects and are either completely displayed (is the label point is inside the clip region object) or ignored. For Point objects. text objects are never clipped.0. and arcs). rasters. Error Conditions ERR_BAD_WINDOW error generated if parameter is not a valid window number. styles (wide lines. The MAPPER_INFO_CLIP_DISPLAY_POLYOBJ uses the Windows Display to selectively perform clipping which mimics the functionality produced by MAPPER_INFO_CLIP_OVERLAY. Since the Overlap( ) function cannot produce result with Text objects. Labels. Clip Region Information Beginning with MapInfo Professional 6.e.5 . a simple point in region test is performed to either include or exclude the Point. and grids are also clipped. ERR_FCN_ARG_RANGE error generated if an argument is outside of the valid range. All rights reserved. Windows Display Clipping is used to clip all Poly Objects (Regions and Polylines) and objects than can be converted to Poly Objects (rectangles. Set Distance Units statement. ERR_WANT_MAPPER_WIN error generated if window id is not a Map window. Coordinate Value Returns MapperInfo( ) does not return coordinates (i. this method should provide better performance that the MAPPER_INFO_CLIP_OVERLAY method. Using this method. All object types are clipped. The MAPPER_INFO_CLIP_OVERLAY method is the method that has been the only option until MapInfo Professional 6. Instead. ellipses. there are three methods that are used for Clip Region functionality. symbols. MINY.0. The MAPPER_INFO_DISPLAY_ALL method uses the Windows Display to perform the clipping. the MAPPER_INFO_XYUNITS attribute returns the units that are used to display the cursor location in the Status Bar (set by using Set Map Window Frontwindow( ) XY Units). the coordinate values are returned in the units of the internal coordinate system of the MapInfo Professional session or the MapBasic application that calls the function (if the coordinate system was changed within the application). rounded rectangles. symbols.MapperInfo( ) function The current state can be changed for a mapper window using the Set Map statement. Thematics. the Overlap( ) function (Object > Erase Outside) is used internally. text) are never clipped. and Text are treated as they would be in the MAPPER_INFO_CLIP_OVERLAY method. MINX. Since the clipping is done at the spatial object level. Also. Set Map statement 376 © 2006 MapInfo Corporation. See Also LayerInfo( ) function. In general. MapBasic 8. Points. MAXY) in the units set for the map window. Styles (wide lines. MAXX. This is the default clipping type. text) are always clipped.

num_expr ) num_expr is a numeric expression. z As Float 42 27 Maximum(x. y) ' z now contains the value: 42 See Also Minimum( ) function MBR( ) function Purpose Returns a rectangle object. All rights reserved. Return Value Float Description The Maximum( ) function returns the larger of two numeric expressions. Example Dim x = y = z = x.Maximum( ) function Maximum( ) function Purpose Returns the larger of two numbers. y. Return Value Object (a rectangle) Reference Guide © 2006 MapInfo Corporation. Syntax MBR( obj_expr ) obj_expr is an object expression. 377 . representing the minimum bounding rectangle (MBR) of another object. Syntax Maximum( num_expr.

An application might hide the menu bar in order to provide more screen room for windows. Every Menu Bar Hide statement should be followed (eventually) by a Menu Bar Show statement. and north to the northern tip of Alaska. but while the menu bar is hidden. Since users can be severely handicapped without the menu bar.obj) See Also Centroid( ) function. See Also Alter Menu Bar statement. CentroidX( ) function. MapBasic 8. west to the western tip of Alaska.Menu Bar statement Description The MBR( ) function calculates the minimum bounding rectangle (MBR) which encompasses the specified obj_expr object. While the menu bar is hidden. For example. Following a Menu Bar Hide statement. CentroidY( ) function Menu Bar statement Purpose Shows or hides the menu bar. MapInfo Professional ignores the Ctrl-O hotkey.5 . Create Menu Bar statement 378 © 2006 MapInfo Corporation. you should be very careful when using the Menu Bar Hide statement. the MBR of the United States extends east to the eastern tip of Maine. All rights reserved. The MBR of a point object has zero width and zero height. the menu bar remains hidden until a Menu Bar Show statement is executed. an MapInfo Professional user might ordinarily press Ctrl-O to bring up the Open dialog box. MapInfo Professional ignores any menu-related hotkeys. south to the southern tip of Hawaii. Example Dim o_mbr As Object Open Table "world" Fetch First From world o_mbr = MBR(world. In other words. Syntax Menu Bar { Hide | Show } Description The Menu Bar statement shows or hides MapInfo Professional's menu bar. A minimum bounding rectangle is defined as being the smallest rectangle which is large enough to encompass a particular object.

MenuItemInfoByHandler( ) function MenuItemInfoByHandler( ) function Purpose Returns information about a MapInfo Professional menu item. For details on menu accelerators. All rights reserved. if the menu item toggles between Show… and Hide…). and the menu item is in its “show” state. Otherwise. see Create Menu statement on page 190. The attribute parameter is a numeric code (defined in MAPBASIC. 379 . also return TRUE if the menu item has alternate menu text (for example. return FALSE. Logical: TRUE if this menu item is checkable (specified by the “!” prefix in the menu text). MapInfo Professional returns information about the first menu item that calls the procedure.DEF) from the following table: attribute setting MENUITEM_INFO_ACCELERATOR Return value String: The code sequence for the menu item's accelerator (for example. Logical: TRUE if the menu item is checkable and currently checked. and call MenuItemInfoByID( ) function instead of calling MenuitemInfoByHandler( ). using the optional ID clause in the Create Menu statement). Syntax MenuItemInfoByHandler( handler. give each menu item an ID number (for example. “/W^Z” or “/W#%119”) or an empty string if the menu item has no accelerator. If you specify a string (a procedure name). and if two or more menu items call that procedure. If you need to query multiple menu items that call the same handler procedure. Description The handler parameter can be an integer or a string. see table below. Logical: TRUE if the menu item is enabled. MENUITEM_INFO_CHECKABLE MENUITEM_INFO_CHECKED MENUITEM_INFO_ENABLED Reference Guide © 2006 MapInfo Corporation. attribute ) handler is either a string (containing the name of a handler procedure specified in a Calling clause) or an integer (which was specified as a constant in a Calling clause). attribute is an integer code indicating which attribute to return.

MENUITEM_INFO_HELPMSG MENUITEM_INFO_ID MENUITEM_INFO_SHOWHIDEABLE MENUITEM_INFO_TEXT See Also MenuItemInfoByID( ) function MenuItemInfoByID( ) function Purpose Returns information about a MapInfo Professional menu item. or 0 if the menu item has no ID.e. An item has alternate text if it was created with “!” at the beginning of the menu item text (in a Create Menu statement or Alter Menu statement) and it has a caret (^) in the string. in a Create Menu statement) to create the menu item.MenuItemInfoByID( ) function attribute setting MENUITEM_INFO_HANDLER Return value Integer: The menu item's handler number. this call returns a unique integer (an internal handler number) which can be used in subsequent calls to MenuitemInfoByHandler( ) or in the Run Menu Command statement. 380 © 2006 MapInfo Corporation. String: the full text used (for example. if the menu item toggles between Show… and Hide…).. If the Calling clause specified “OLE”. attribute ) menuitem_ID is an integer menu ID (specified in the ID clause in Create Menu). If the menu item's Calling clause specified a numeric constant (for example. Logical: TRUE if this menu item has alternate menu text (i. this call returns the value of the constant. Syntax MenuItemInfoByID( menuitem_ID. Calling M_FILE_SAVE). attribute is an integer code indicating which attribute to return. “DDE”. All rights reserved. MapBasic 8.5 . String: the menu item's help message (as specified in the HelpMsg clause in Create Menu statement) or empty string if the menu item has no help message. Integer: The menu ID number (specified in the optional ID clause in a Create Menu statement). or the name of a procedure.

representing the value to assign to the key. representing the name of a metadata key. For a listing of codes you can use. Syntax 2 Metadata Traverse traverse_ID { Next Into Key key_name_var In key_value_var | Destroy } traverse_ID is an integer value (such as the value of the traverse_ID_var variable described above). see MenuItemInfoByHandler( ) function on page 379. MapInfo Professional stores the fetched key's name in this variable. specify “\” (backslash). All rights reserved. except that the first argument to this function is an integer ID.Metadata statement Description This function is identical to the MenuItemInfoByHandler( ) function. The string must start with a backslash (“\”). traverse_ID_var is the name of an integer variable. starting_key_name is a string representing the first key name to retrieve from the table. Call this function to query the status of a menu item when you know the ID of the menu item you need to query. MapInfo Professional stores a traversal ID in the variable. key_value is a string up to 239 characters long. key_name_var is the name of a string variable. See Also MenuItemInfoByHandler( ) function Metadata statement Purpose Manages a table's metadata. such as MENUITEM_INFO_CHECKED. Syntax 1 Metadata Table table_name { SetKey key_name To key_value | DropKey key_name [ Hierarchical ] | SetTraverse starting_key_name [ Hierarchical ] Into ID traverse_ID_var } table_name is the name of an open table. The attribute argument is a code from MAPBASIC. which you can use in subsequent Metadata Traverse… statements. To set up the traversal at the very beginning of the list of keys. and it cannot end with a backslash. key_name is a string.DEF. Call the MenuItemInfoByHandler( ) function to query the status of a menu item if you would rather identify the menu item by its handler. 381 . Reference Guide © 2006 MapInfo Corporation.

5 . MapInfo Professional assigns it a new value. and then use the Next clause to fetch key values. etc. MapBasic 8. Metadata is information that is stored in a table's . 382 © 2006 MapInfo Corporation. The following clauses apply: SetKey Assigns a value to a metadata key. starting with the specified key. reserved for internal use by MapInfo Professional. If you include the Hierarchical keyword. use the Destroy clause to free the memory used by the traversal. All rights reserved. if a table has the keys “\Info\Author” and “\Info\Date” you can delete both keys with the following statement: MetaData Table Parcels DropKey "\Info" Hierarchical Reading a Table's Metadata To read a table's metadata values. specify “\” as the starting key name. Each table can have zero or more keys. modify. Description The Metadata statement manages the metadata stored in MapInfo tables. For example. MapInfo Professional stores the fetched key's value in this variable. see the MapBasic User Guide. For example.Metadata statement key_value_var is the name of a string variable. To start at the beginning of the list of keys.TAB file. MapInfo Professional deletes the entire metadata hierarchy at and beneath the specified key. use Syntax 1. Each key has a string value associated with it. but not the “\Info\Date” key). use the SetTraverse clause to initialize a traversal. MetaData Table Parcels SetKey "\Info\Date" To Str$(CurDate( )) Note: MapInfo Professional automatically creates a metadata key called “\IsReadOnly” (with a default value of “FALSE”) the first time you add a metadata key to a table. or delete metadata. The following clauses apply: SetTraverse Prepares to traverse the table's keys. a key called “\Copyright” might have the value “Copyright 2001 MapInfo Corporation. Modifying a Table's Metadata To create.” For more information about Metadata. DropKey Deletes the specified key from the table. the changes take effect immediately. If the key already exists. MapInfo Professional creates a new key. meaning that MapInfo Professional will only fetch keys at the root level (for example. a copyright notice. When you create a new key. If the key does not exist. you do not need to perform a Save operation. After you are finished fetching key values. If you include the Hierarchical keyword. the traversal is flat. Each key represents an information category. the traversal can hierarchically fetch every key. instead of being stored as rows and columns. The \IsReadOnly key is a special key. the traversal will fetch the “\Info” key. If you omit the Hierarchical keyword. such as an author's name.

Metadata statement Next Into Key… Into Value… Attempts to read the next key. the table name is specified by the caller. begin the traversal at “\One\Two\Three\Four\Five”). and print it to the Message window. “\One\Two\Three\Four\Five\Six\Seven\Eight\Nine\Ten”) if you begin the traversal at the root level (“\”). Sub Print_Metadata(ByVal table_name As String) Dim i_traversal As Integer Dim s_keyname. If there is a key to read. MapInfo Professional stores the key's name in the key_name_var variable. begin the traversal at a deeper level (for example. 383 . retrieve ' one key. TableInfo( ) function Reference Guide © 2006 MapInfo Corporation. and frees the memory that was used by the traversal. Do While s_keyname <> "" Print " " Print "Key name: " & s_keyname Print "Key value: " & s_keyvalue Metadata Traverse i_traversal Next Into Key s_keyname Into Value s_keyvalue Loop ' Release this traversal to free memory: MetaData Traverse i_traversal Destroy End Sub See Also GetMetadata$( ) function. If you need to retrieve a key that is more than ten levels deep. If there are no more keys to read. Destroy Ends the traversal. MapInfo Professional stores empty strings in both variables. s_keyvalue As String ' Initialize the traversal: Metadata Table table_name SetTraverse "\" Hierarchical Into ID i_traversal ' Attempt to fetch the first key: Metadata Traverse i_traversal Next Into Key s_keyname Into Value s_keyvalue ' Now loop for as long as there are key values. All rights reserved. This procedure prints the key names and key values to the Message window. and stores the key's value in the key_value_var variable. Example The following procedure reads all metadata values from a table. Note: A hierarchical metadata traversal can traverse up to ten levels of keys (for example. ' with each iteration of the loop.

MapBasic 8. Syntax MGRSToPoint( string ) string is a string expression representing an MGRS coordinate.263) s_mgrs = PointToMGRS$(obj1) obj2 = MGRSToPoint(s_mgrs) Example 2: Open Table "C:\Temp\MyTable. Example Example 1: dim obj1 as Object dim s_mgrs As String dim obj2 as Object obj1 = CreatePoint(-74. The default Longitude/Latitude coordinate system is used as the initial selection.MGRSToPoint( ) function MGRSToPoint( ) function Purpose Converts a string representing an MGRS (Military Grid Reference System) coordinate into a point object in the current MapBasic coordinate system.669. set the MapBasic coordinate system to match the destination table's coordinate system before calling MGRSToPoint( ). 'Set the MapBasic coordsys to that of the table used Set CoordSys Table MGRSfile 384 © 2006 MapInfo Corporation.TAB" as MGRSfile ' ' ' ' When using the PointToMGRS$( ) or MGRSToPoint( ) functions. which can cause a significant loss of precision. it is very important to make sure that the current MapBasic coordsys matches the coordsys of the table where the point object is being stored. This will prevent MapInfo Professional from doing an intermediate conversion to the datumless Long/Lat coordinate system. All rights reserved. Return Value Object Description The returned point will be in the current MapBasic coordinate system. 43. For the most accurate results when saving the resulting points to a table. which by default is Long/Lat (no datum).5 .

indicating the number of characters to extract. Mid$( ) copies length characters from the string_expr string. Syntax Mid$( string_expr.Mid$( ) function 'Update a Character column (for example COL2) with MGRS strings from 'a table of points Update MGRSfile Set Col2 = PointToMGRS$(obj) 'Update two float columns (Col3 & Col4) with 'CentroidX & CentroidY information 'from a character column (Col2) that contains MGRS strings. Return Value String Description The Mid$( ) function returns a substring copied from the specified string_expr string. A position value less than or equal to one tells MapBasic to copy from the very beginning of the string_expr string. Update MGRSfile Set Col3 = CentroidX(MGRSToPoint(Col2)) Update mgrstestfile ' MGRSfile Set Col4 = CentroidY(MGRSToPoint(Col2)) Commit Table MGRSfile Close Table MGRSfile See Also PointToMGRS$( ) function Mid$( ) function Purpose Returns a string extracted from the middle of another string. Reference Guide © 2006 MapInfo Corporation. position. All rights reserved. length is a numeric expression. position is a numeric expression. starting at the character position indicated by position. indicating a starting position in the string. length ) string_expr is a string expression. 385 .

MidByte$( ) function If the string_expr string is not long enough. depending on all of the parameters. Return Value String Description The MidByte$( ) function returns individual bytes of a string. substr_var As String str_var = "New York City" substr_var = Mid$(str_var. MapBasic 8. and the application is running on a system that uses a double-byte character set (DBCS systems). indicating a starting position in the string. Right$( ) function MidByte$( ) function Purpose Accesses individual bytes of a string on a system with a double-byte character system. Left$( ) function. there may not be length characters to copy. the Mid$( ) may or may not return a string length characters long. If the position parameter represents a number larger than the number of characters in string_ expr. the results returned by the MidByte$( ) function are identical to the results returned by the Mid$( ) function. See Also InStr( ) function. If the length or position parameters are fractional. indicating the number of bytes to return. For example. Left$( ) function. All rights reserved. length is an integer numeric expression. Use the MidByte$( ) function when you need to extract a range of bytes from a string. thus. the Japanese version of Microsoft Windows uses a double-byte character system. length ) string_expr is a string expression. On systems with single-byte character sets.5 . 4) ' substr_var now contains the string "City" See Also InStr( ) function. Example Dim str_var. Mid$( ) returns a null string. 10. position is an integer numeric expression. Right$( ) function 386 © 2006 MapInfo Corporation. MapBasic rounds to the nearest integer. If the length parameter is zero. position. Mid$( ) returns a null string. Syntax MidByte$( string_expr.

Syntax Month( date_expr ) date_expr is a date expression. y) ' z now contains the value: -100 See Also Maximum( ) function Month( ) function Purpose Returns the month component (1 . 387 . y. Return Value SmallInt value from 1 to 12. inclusive. Return Value Float Description The Minimum( ) function returns the smaller of two numeric expressions. Reference Guide © 2006 MapInfo Corporation. Example Dim x = y = z = x. z As Float 42 -100 Minimum(x. All rights reserved. num_expr ) num_expr is a numeric expression. Syntax Minimum( num_expr.12) of a date value.Minimum( ) function Minimum( ) function Purpose Returns the smaller of two numbers.

The Select statement's Where clause tells MapInfo Professional to only select the orders from December of 1993. then a distance object is created for every combination. All rights reserved. If All is used. The following Select statement extracts only particular rows from the Orders table. Open Table "orders" Select * From orders Where Month(orderdate) = 12 And Year(orderdate) = 1993 See Also CurDate( ) function. Year( ) function Nearest statement Purpose Find the object in a table that is closest to a particular object. called Order_Date. Examples The following example shows how you can extract just the month component from a particular date value. fromtable represents a table of objects that you want to find closest distances from. The default is 1.. ' End If You can also use the Month( ) function within the SQL Select statement..5 . using the Month( ) function. Weekday( ) function. fromvar represents a MapBasic variable representing an object that you want to find the closest distances from.. If Month(CurDate( )) = 12 Then ' ' . This example assumes that the Orders table has a Date column. representing the month component (one to twelve) of the specified date. MapBasic 8. Day( ) function. then it is December. Syntax Nearest [ N | All ] From { Table fromtable | Variable fromvar } To totable Into intotable [ Type { Spherical | Cartesian }] [ Ignore [ Contains ] [ Min min_value ] [ Max max_value ] Units unitname ] [ Data clause ] N is an optional parameter representing the number of “nearest” objects to find.Nearest statement Description The Month( ) function returns an integer.. 388 © 2006 MapInfo Corporation. The result is a 2-point Polyline object representing the closest distance.

then an object is placed in the intotable representing the distance between the fromtable object and each totable object. if N is greater than 1). then objects of the same distance will fill subsequent slots. then the minimum distance is zero. max_value is the maximum distance to include in the results. If there are multiple objects in the totable that are the same distance from a given fromtable object. unitname is string representing the name of a distance unit (for example. For example. If the coordinate system of the intotable is NonEarth and the distance method is Spherical. if both tables contain Region objects. For example. where both points are identical and represent a point of intersection. One use of the Min distance could be to eliminate distances of zero. If multiple objects are requested (i. This may result in less than five Reference Guide © 2006 MapInfo Corporation. and the distance method is Cartesian. The distances calculated do not take into account any road route distance. and we want to find the closest cities. If the tie exists at the second closest object. For example. Type is the method used to calculate the distances between objects. All rights reserved. an error will occur. if there are two point tables representing Cities. then only one of them may be returned. as are the Min and Max subclauses within it. The Max distance can be used to limit the objects to consider in the totable. The types of the objects in the fromtable and totable can be anything except Text objects. It can either be Spherical or Cartesian. we may want to search for the five airports that are closest to a set of cities (where the fromtable is the set of cities and the totable is a set of airports). The entire Ignore clause is optional. For each object in the fromtable. and three objects are requested. If All is specified. min_value is the minimum distance to include in the results. then an error will occur. Every object in the fromtable is considered.e. and the two-point Polyline object produced represents the points on each object used to calculate that distance. “km”) used for min_value and/or max_value.Nearest statement totable represents a table of objects that you want to find closest distances to. A two-point Polyline object representing the closest points between the fromtable object and the chosen totable object is placed in the intotable. Description The Nearest statement finds all the objects in the fromtable that are nearest to a particular object. the nearest object in the totable is found. then the object will become the third closest object. If N is defined. but we don't care about airports that are farther away than 100 miles. then an error will occur. This may be most useful in conjunction with N or All. If the coordinate system of the intotable is Latitude/ Longitude. then the minimum distance between Region objects is found. and the two-point Polyline returned will be degenerate. This may be useful in the case of two point tables to eliminate comparisons of the same point. If unitname is not a valid distance unit. Any distances found which are less than or equal to min_value or greater than max_value are ignored.. The type of distance calculation must be correct for the coordinate system of the intotable or an error will occur. 389 . clause is an expression that specifies the tables that the results come from. min_value and max_value are in the distance unit signified by unitname. then the N nearest objects in totable are found. we may want to exclude cases of the same city. If the Region objects intersect. intotable represents a table to place the results into. The Ignore clause limits the distances returned. It is strictly a “as the bird flies” distance.

such as regions. this will treat all closed objects. totable is searched first for column names on the right hand side of the equals sign). IntoColumn2=column2 The IntoColumn on the left hand side of the equals must be a valid column in intotable. In effect.5 . the distance between the objects is zero. To avoid any conflicts such as this. and the second pass may return all objects between 100 and 200 miles. MapBasic 8. then the distance between London and the United Kingdom would be zero. if one object is contained within another object. Assume that the current selection represents our current location. Supplying a Max parameter can improve the performance of the Nearest statement. Then the following will find the closest ATM to where we currently are: Nearest From Table selection To atm Into result Data where=Business. the first pass may return all objects between 0 and 100 miles. All rights reserved. which represents the name of the business which contains the ATM. as polylines for the purpose of this operation.state_name To fill a column in the intotable with the distance. If the Contains flag is set within the Ignore clause. and Address. Instead. where we would find all airports within 100 miles of a city.e. since it effectively limits the number of totable objects that are searched. Data Clause The Data clause can be used to mark which fromtable object and which totable object the result came from. Examples Assume that we have a point table representing locations of ATM machines and that there are at least two columns in this table: Business. the column names can be qualified using the table alias: Data name1=states. which represents the street address of that business. The effective distances found are strictly greater than the min_value and less than or equal to the max_value: min_value < distance <= max_value This can allow ranges or distances to be returned in multiple passes using the Nearest statement.address=Address 390 © 2006 MapInfo Corporation. if the fromtable is WorldCaps and the totable is World. we can either use the Table > Update Column functionality from the menu or use the Update statement. For example. The column name on the right hand side of the equals sign must be a valid column name from either totable or fromtable. a distance of 100 should only occur in the first pass and never in the second pass). If the same column name exists in both totable and fromtable. then the column in totable will be used (e.. name2=county. and the results should not contain duplicates (i.state_name. the distance from London to the boundary of the United Kingdom will be returned.Nearest statement airports being returned for a given city. For example.. This could also be used in conjunction with the All parameter. Data IntoColumn1=column1.g. Normally. then the distance will not be automatically be zero.

Note statement If we wanted to find the closest five ATM machines to our current location: Nearest 5 From Table selection To atm Into result Data where=Business.name.county. To find the distance from a given house to the coastline: Nearest From Table customer To coastline Into result Data who=customer.type=coastline. SphericalObjectDistance( ) function. CartesianConnectObjects( ) function. type=coastline.address.address. the message dialog box remains on the screen until the user clicks the OK button.designation Assume we have a table of cities (the fromtable) and another table of state capitals (the totable). The dialog box contains an OK button.name.capital=usa_caps.designation If we don't care about customer locations which are greater than 30 miles from any coastline: Nearest From Table customer To coastline Into result Ignore Max 30 Units "mi" Data who=customer. Description The Note statement creates a dialog box to display a message. ObjectDistance( ) function. Reference Guide © 2006 MapInfo Corporation. where=customer. CartesianObjectDistance( ) function. ConnectObjects( ) function. 391 . where=customer.address=Address If we want to find all ATM machines within a 5 mile radius: Nearest All From Table selection To atm Into result Ignore Max 5 Units "mi" Data where=buisness. and we want to find the closest state capital to each city. but we want to ignore the case where the city in the fromtable is also a state capital: Nearest From Table uscty_1k To usa_caps Into result Ignore Min 0 Units "mi" Data city=uscty_1k.address=address Assume we have a table of house locations (the fromtable) and a table representing the coastline (the totable). Syntax Note message message is an expression to be displayed in a dialog box.capital See Also Farthest statement.coast_ loc=coastline.coast_ loc=coastline.name. SphericalConnectObjects( ) function Note statement Purpose Displays a simple message in a dialog box. All rights reserved.county.

Example Note "Total # of records processed: " + Str$( i_count ) See Also Ask( ) function. WindowID( ) function NumberToDate( ) function Purpose Returns a Date value. MapBasic will automatically produce an appropriate string (for example. given an integer. and can occupy up to 6 rows. Syntax NumberToDate( numeric_date ) numeric_date is an eight-digit integer in the form YYYYMMDD (for example. Syntax NumAllWindows( ) Return Value SmallInt Description The NumAllWindows( ) function returns the number of windows owned by MapInfo Professional. Dialog statement. Print statement NumAllWindows( ) function Purpose Returns the number of windows owned by MapInfo Professional. call NumWindows( ). the string can be up to 300 characters long. including special windows such as ButtonPads and the Info window. 392 © 2006 MapInfo Corporation. To determine the number of document windows opened by MapInfo Professional (Map.5 . MapBasic 8. 19951231). All rights reserved. “Region”) for display in the Note dialog box. If the message expression is a string.NumAllWindows( ) function The message expression does not need to be a string expression. and Layout windows). If message is an object expression. See Also NumWindows( ) function. Graph. Browse.

Syntax NumCols( table ) table is the name of an open table. 2006: NumberToDate(20061231) Example The following example subtracts one Date value from another Date. The number of columns returned by NumCols( ) does not include the special column known as Object (or Obj for short). the following function call returns a Date value of December 31.NumberToDate(20060101) ' i_elapsed now contains the number of days ' since January 1.NumCols( ) function Return Value Date Description The NumberToDate( ) function returns a Date value represented by an eight-digit integer. 2006 See Also StringToDate( ) function NumCols( ) function Purpose Returns the number of columns in a specified table. All rights reserved. the number returned by NumCols( ) includes the temporary column(s). The result of the subtraction is the number of days between the two dates. which refers to the graphical objects attached to mappable tables. 393 . Return Value SmallInt Description The NumCols( ) function returns the number of columns contained in the specified open table. because of an Add Column statement). Reference Guide © 2006 MapInfo Corporation. Similarly. Note: If a table has temporary columns (for example. Dim i_elapsed As Integer i_elapsed = CurDate( ) . the number of columns returned does not include the special column known as RowID. For example.

TAB and DCWASHS2. TableInfo( ) function.NumTables( ) function Error Conditions ERR_TABLE_NOT_FOUND error generated if the specified table is not available. A street-map table may consist of two “companion” tables. MapInfo Professional treats the DCWASHS table as a single table. Example If NumTables( ) < 1 Then Note "You must open a table before continuing. Example Dim i_counter As Integer Open Table "world" i_counter = NumCols(world) See Also ColumnInfo( ) function. TableInfo( ) function NumTables( ) function Purpose Returns the number of tables currently open." End If See Also Open Table statement. Syntax NumTables( ) Return Value SmallInt Description The NumTables( ) function returns the number of tables that are currently open. However. Similarly. DC street map named DCWASHS. All rights reserved. For example. the NumTables( ) function counts a street map as a single table. MapInfo Professional secretly opens the two companion tables DCWASHS1. for example. the Layer Control dialog box shows only the table name DCWASHS. MapBasic 8. when you open the Washington.5 . although it may actually be composed of two companion tables.TAB. NumTables( ) function. ColumnInfo( ) function 394 © 2006 MapInfo Corporation.

Graph. Graph. To determine the total number of windows opened by MapInfo Professional (including ButtonPads and special windows such as the Info window). and Layout windows that are currently open. All rights reserved. Layout). call NumAllWindows( ). 395 . The result is independent of whether windows are minimized or not. Browse. Example Dim num_open_wins As SmallInt num_open_wins = NumWindows( ) See Also NumAllWindows( ) function. Syntax NumWindows( ) Return Value SmallInt Description The NumWindows( ) function returns the number of Map. WindowID( ) function Reference Guide © 2006 MapInfo Corporation. Browse.NumWindows( ) function NumWindows( ) function Purpose Returns the number of open document windows (Map.

unit_name is a string representing the name of a distance unit. Return Value Float Description The attribute parameter controls which type of information will be returned. MapBasic 8. If the calculation cannot be done using a spherical distance method (e. then a cartesian distance method will be used. codes in the left column (for example. attribute ) object is an Object expression. All rights reserved. Syntax ObjectGeography( object.ObjectDistance( ) function ObjectDistance( ) function Purpose Returns the distance between two objects..5 . 396 © 2006 MapInfo Corporation. object2.DEF. OBJ_GEO_MINX) are defined in MAPBASIC. if the MapBasic Coordinate System is NonEarth). ObjectGeography( ) function Purpose Returns coordinate or angle information describing a graphical object.g. unit_name ) object1 and object2 are object expressions. attribute is an integer code specifying which type of information should be returned. Syntax ObjectDistance( object1. The table below summarizes the different codes that you can use as the attribute parameter. Return Value Float Description ObjectDistance( ) returns the minimum distance between object1 and object2 using a spherical calculation method with the return value in unit_name.

This is most commonly used with the Alter Object statement.ObjectGeography( ) function Some attributes apply only to certain types of objects. Y-coordinate of the starting node of a Line object.or m-values. Maximum x-coordinate of object's MBR. and text objects are the only objects with the text-angle attribute. For lines. arc objects are the only objects with begin-angle or end-angle attributes. Returns a point object for centroid of regions. X-coordinate of a Point object. For lines. For example. 397 . X-coordinate of the ending node of a Line object. unless the object is a line. or a z. X-coordinate of the starting node of a Line object. if the object is a line. Z-value of a Point object. Minimum y-coordinate of object's MBR. Beginning angle of an Arc object. For lines. returns OBJ_GEO_LINEENDX value. Maximum y-coordinate of the object's MBR. Does not apply to Point objects. Diameter of the circle that defines the rounded corner of a Rounded Rectangle object. All rights reserved. OBJ_GEO_MINY OBJ_GEO_MAXX OBJ_GEO_MAXY OBJ_GEO_ARCBEGANGLE OBJ_GEO_ARCENDANGLE OBJ_GEO_LINEBEGX OBJ_GEO_LINEBEGY OBJ_GEO_LINEENDX OBJ_GEO_LINEENDY OBJ_GEO_POINTX OBJ_GEO_POINTY OBJ_GEO_POINTZ OBJ_GEO_POINTM OBJ_GEO_ROUNDRADIUS OBJ_GEO_CENTROID OBJ_GEO_TEXTLINEX Reference Guide © 2006 MapInfo Corporation. Y-coordinate of the ending node of a Line object. returns OBJ_GEO_LINEENDY value. then an error is thrown. If an object does not support z. expressed in terms of coordinate units (for example. returns same value as OBJ_GEO_LINEBEGX. Does not apply to Point objects. returns OBJ_ GEO_LINEBEGY value. M-value of a Point object. degrees). Ending angle of an Arc object.or m-value for this node is not defined. collections. multipoints. attribute setting OBJ_GEO_MINX Return value (Float) Minimum x-coordinate of an object's minimum bounding rectangle (MBR). and polylines. Y-coordinate of a Point object. X-coordinate of the end of a Text object's label line.

The ObjectGeography( ) function has been extended to support Multipoints and Collections. or other values describing a graphical object. ObjectInfo( ) function ObjectInfo( ) function Purpose Returns Pen. Maximum y-coordinate of an object's MBR. OBJ_INFO_TYPE) If i_obj_type = OBJ_LINE Then f_x = ObjectGeography(city. OBJ_GEO_LINEBEGX) f_y = ObjectGeography(city. Minimum y-coordinate of an object's MBR. f_y As Float Open Table "city" Map From city Fetch First From city ' at this point.ObjectInfo( ) function attribute setting OBJ_GEO_TEXTLINEY OBJ_GEO_TEXTANGLE Return value (Float) Y-coordinate of the end of a Text object's label line. Rotation angle of a Text object. All rights reserved. f_x.obj.DEF" Dim i_obj_type As Integer. OBJ_GEO_LINEBEGY) Set Map Center (f_x. i_obj_type = ObjectInfo(city. Both types support attributes 1 . attribute ) 398 © 2006 MapInfo Corporation. .obj ' represents the graphical object that's attached ' to the first record of the CITY table.4 (coordinates of object's minimum bounding rectangle (MBR).5 . f_y) End If See Also Centroid( ) function. OBJ_GEO_MINX (1) OBJ_GEO_MINY (2) OBJ_GEO_MAXX (3) OBJ GEO_MAXY (4) Minimum x-coordinate of an object's MBR.obj.obj. CentroidY( ) function. A Set Map statement then uses these coordinates to re-center the Map window. Maximum x-coordinate of an object's MBR. CentroidX( ) function. Include "MAPBASIC. MapBasic 8. Syntax ObjectInfo( object. the expression: ' city. Example The following example reads the starting coordinates of a line object from the table City. Brush.

Pen. attribute Setting OBJ_INFO_TYPE (1) Return Value SmallInt. Region. This attribute from the DEF file is 1 (ObjectInfo( Object. Ellipse. Symbol. if you need to find out several pieces of information about an object. with different attribute values in each call. Pen style is returned. the name of an Object variable. The first parameter should be an object value (for example. Frame. or a region. you will need to call ObjectInfo( ) a number of times. The table below summarizes the various attribute settings. Frame. a line. Thus.ObjectInfo( ) function object is an Object expression. Each object has several attributes. 1 )). etc. the return value is one of the values listed in the table below (for example. All rights reserved. string. ObjectInfo( ) returns a value of 4 for a triangle-shaped region. attribute is an integer code specifying which type of information should be returned. The ObjectInfo( ) function returns one attribute of the specified object. and the corresponding return values. each object has a “type” attribute. OBJ_TYPE_LINE). float. representing the object type. which dictate the object's appearance. 399 . or Font. Rectangle. For example. Regions. OBJ_INFO_NPOLYGONS+N (21) is an integer that indicates the number of nodes in the Nth polygon of a region or the Nth section of a polyline. MapInfo Professional counts the starting node twice (once as the start node and once as the end node). Line. integer. and Rounded Rectangle. Description The ObjectInfo( ) function returns general information about one aspect of a graphical object. Rectangle. Brush. OBJ_INFO_PEN (2) OBJ_INFO_BRUSH (3) Reference Guide © 2006 MapInfo Corporation.obj). Return Value SmallInt. depending on the attribute parameter OBJ_INFO_NPOLYGONS (21) is an integer that indicates the number of polygons (in the case of a region) or sections (in the case of a polyline) which make up an object. For example. Brush style is returned. Polyline. this query is only valid for the following object types: Ellipse. and Rounded Rectangle. Note: With region objects. identifying whether the object is a point. Which attribute is returned depends on the value used in the attribute parameter. this query is only valid for the following object types: Arc. Most types of objects have Pen and/or Brush attributes. or a table expression of the form tablename.

Logical. SmallInt. this query is only valid for Point objects. OBJ_INFO_SYMBOL (2) OBJ_INFO_NPNTS (20) Symbol style. Note: If the Text object is contained in a mappable table (as opposed to a Layout window). Integer. indicating the window ID of the window attached to a Frame object. representing a Text object's line spacing. MapInfo Professional counts the starting node twice (once as the start node and once as the end node). indicating the number of nodes in the Nth polygon of a region or the Nth section of a polyline. 1. and the text height is controlled by the Map window's zoom distance. OBJ_INFO_SMOOTH (4) OBJ_INFO_FRAMEWIN (4) OBJ_INFO_FRAMETITLE (6) OBJ_INFO_NPOLYGONS (21) OBJ_INFO_NPOLYGONS+N (21) OBJ_INFO_TEXTSPACING (4) OBJ_INFO_TEXTJUSTIFY (5) OBJ_INFO_TEXTARROW (6) OBJ_INFO_FILLFRAME (7) 400 © 2006 MapInfo Corporation. Float value of 1. if the object has multiple lines of text. SmallInt. 1 = simple line. 2 = right. String. the Font specifies a point size of zero. For example. indicating the number of polygons (in the case of a region) or sections (in the case of a polyline) which make up an object. indicating whether the specified Polyline object is smoothed.ObjectInfo( ) function attribute Setting OBJ_INFO_TEXTFONT (2) Return Value Font style is returned. SmallInt. representing the line style associated with a Text object: 0 = no line. representing justification of a Text object: 0 = left. Logical: TRUE if the object is a frame that contains a Map window. OBJ_INFO_TEXTSTRING (3) String.5 . 1 = center. indicating a Frame object's title. this query is only valid for Text objects. or 2. ObjectInfo( ) returns a value of 4 for a triangle-shaped region. representing the body of a Text object. Integer. 2 = arrow line. MapBasic 8.5. Integer. Note: With region objects. indicating the total number of nodes in a polyline or region object. the string includes embedded linefeeds (Chr$( 10 ) values). All rights reserved. and the frame's “Fill Frame With Map” setting is checked.

401 . indicating whether the object has z-values. MAPBASIC. or FALSE if the object is empty. Your program should Include “MAPBASIC. For example. Object value representing polyline part of a collection object. Each graphic attribute only applies to some types of graphic objects. OBJ_INFO_REGION (8) OBJ_INFO_PLINE (9) OBJ_INFO_MPOINT (10) OBJ_INFO_Z_UNIT_SET(12) OBJ_INFO_Z_UNIT(13) OBJ_INFO_HAS_Z(14) OBJ_INFO_HAS_M(15) The codes in the left column (for example.DEF” if you intend to call the ObjectInfo( ) function. it returns an empty polyline object. OBJ_INFO_TYPE values OBJ_INFO_TYPE values OBJ_TYPE_ARC OBJ_TYPE_ELLIPSE OBJ_TYPE_LINE Corresponding object type Arc object Ellipse / circle objects Line object Reference Guide © 2006 MapInfo Corporation. the ObjectInfo( ) function cannot return every type of attribute setting for every type of object. OBJ_INFO_TYPE) are defined through the MapBasic definitions file. Returns an empty string if units are not specified. This query is valid only for collection objects. it returns an empty Multipoint object. Object value representing the Multipoint part of a collection object. the ObjectInfo( ) function returns one of the object types listed in the table below. String result: indicates distance units used for z-values. If the collection object does not have a Multipoint. indicating whether the object has m-values. This query is valid only for collection objects. If the collection object does not have a region. Logical. All rights reserved. point objects are the only objects with Symbol attributes. returns TRUE if a Multipoint object has nodes. Logical. If you specify OBJ_INFO_TYPE as the attribute setting. Object value representing the region part of a collection object.DEF.ObjectInfo( ) function attribute Setting OBJ_INFO_NONEMPTY (11) Return Value Logical. indicating whether z units are defined. If the collection object does not have a polyline. it returns an empty region. Logical. and text objects are the only objects with Font attributes. Therefore. This query is valid only for collection objects.

." counter = ObjectInfo(city. obj_type As Integer Open Table "city" Fetch First From city ' at this point. Pen clause. OBJ_INFO_TYPE) Do Case obj_type Case OBJ_TYPE_LINE Note "First object is a line.ObjectInfo( ) function OBJ_INFO_TYPE values (continued) OBJ_INFO_TYPE values OBJ_TYPE_PLINE OBJ_TYPE_POINT OBJ_TYPE_FRAME OBJ_TYPE_REGION OBJ_TYPE_RECT OBJ_TYPE_ROUNDRECT OBJ_TYPE_TEXT OBJ_TYPE_MULTIPOINT Corresponding object type Polyline object Point object Layout window Frame object Region object Rectangle object Rounded rectangle object Text object Collection text object Example Include "MAPBASIC.. OBJ_INFO_NPOLYGONS+1) Note "The 1st polygon has" + Str$(counter) + " nodes" End Case See Also Alter Object statement. All rights reserved.obj. obj_type = ObjectInfo(city." counter = ObjectInfo(city.obj. Brush clause. MapBasic 8.. OBJ_INFO_NPOLYGONS) Note ".obj ' represents the graphical object that's attached ' to the first record of the CITY table.5 . Font clause. OBJ_INFO_NPNTS) Note " .. ObjectGeography( ) function." Case OBJ_TYPE_PLINE Note "First object is a polyline. made up of " + Str$(counter) + " polygons. with " + Str$(counter) + " nodes." Case OBJ_TYPE_REGION Note "First object is a region.obj." counter = ObjectInfo(city... the expression: city. Symbol clause 402 © 2006 MapInfo Corporation.DEF" Dim counter.obj...

to measure the circumference of a rectangle. Syntax ObjectLen( expr. to obtain a length in miles. a Cartesian operation is performed. Perimeter( ) function. Set Distance Units statement Reference Guide © 2006 MapInfo Corporation. 403 .ObjectLen( ) function ObjectLen( ) function Purpose Returns the geographic length of a line or polyline object. specify “mi” as the unit_name parameter. Note that only line and polyline objects have length values greater than zero. or region. Generally. The ObjectLen( ) function returns a length measurement in the units specified by the unit_name parameter. "mi") ' geogr_length now represents the length of the ' street segment. in miles See Also Distance( ) function. “mi” for miles). unit_name is a string representing the name of a distance unit (for example. Example Dim geogr_length As Float Open Table "streets" Fetch First From streets geogr_length = ObjectLen(streets. Return Value Float Description The ObjectLen( ) function returns the length of an object expression. All rights reserved. MapInfo Professional performs a Cartesian or Spherical operation. ellipse. a Spherical operation is performed unless the coordinate system is nonEarth. See Set Distance Units statement on page 570 for the list of valid unit names. unit_name ) expr is an object expression. For the most part. in which case.obj. use the Perimeter( ) function. for example.

If the first object is a polyline.ObjectNodeHasM( ) function ObjectNodeHasM( ) function Purpose Returns TRUE if a specific node in a region. Return Value Logical Description The ObjectNodeHasM( ) function returns TRUE if the specific node from a region. polygon_num. The node_num parameter must have a value of one or more. m As Float hasZ. MapBasic 8. or multipoint object has an m-value. The polygon_num parameter must have a value of one or more. It is ignored for Multipoint objects (it used for regions and polylines). The ObjectNodeHasM( ) function supports Multipoint objects and returns TRUE if a specific node in a Multipoint object has an m-value. node_num ) object is an Object expression. z. This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried. Example The following example queries the first graphic object in the table Routes. 404 © 2006 MapInfo Corporation. hasM as Logical Open Table "routes" Fetch First From routes ' at this point. Dim i_obj_type As SmallInt. Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. polyline. You can use the ObjectInfo( ) function to determine the number of nodes in an object. polygon_num is a positive integer value indicating which polygon or section to query. All rights reserved.5 . If the object does not support m-values or an m-value for this node is not defined. the expression: ' routes. node_num is a positive integer value indicating which node to read. polyline or multipoint object has an m-value. the program queries if the first node in the object has z-coordinates or m-values and queries z-coordinates and m-values of the first node in the polyline. this tells MapBasic which of the object's nodes should be queried. it returns FALSE. Syntax ObjectNodeHasM( object.obj ' represents the graphical object that's attached ' to the first record of the routes table.

1)) Then m = ObjectNodeM(routes. it returns FALSE. 1.obj. node_num ) object is an Object expression. The ObjectNodeHasZ( ) function supports Multipoint objects and returns TRUE if a specific node in a Multipoint object has a z-coordinate. polygon_num is a positive integer value indicating which polygon or section to query. 1. 1) ' read z-coordinate End If If (ObjectNodeHasM(routes. Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. this tells MapBasic which of the object's nodes should be queried. All rights reserved. 1. If (ObjectNodeHasZ(routes. ObjectInfo( ) function ObjectNodeHasZ( ) function Purpose Returns TRUE if a specific node in a region.obj. or multipoint object has a z-coordinate... Reference Guide © 2006 MapInfo Corporation. This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried.. polyline. or multipoint object has a z-coordinate Syntax ObjectNodeHasZ( object. polygon_num.ObjectNodeHasZ( ) function i_obj_type = ObjectInfo(routes. The node_num parameter must have a value of one or more.obj. The polygon_num parameter must have a value of one or more. 405 . OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' . 1) ' read m-value End If End If See Also Querying Map Objects.. It is ignored for Multipoint objects (it used for regions and polylines).obj.obj. polyline. node_num is a positive integer value indicating which node to read. Return Value Logical Description The ObjectNodeHasZ( ) function returns TRUE if a specific node from a region. then the object is a polyline. 1)) Then z = ObjectNodeZ(routes. If object does not support z-coordinates or a z-coordinate for this node is not defined. You can use the ObjectInfo( ) function to determine the number of nodes in an object. 1.

1)) Then z = ObjectNodeZ(routes. 1)) Then m = ObjectNodeM(routes. polygon_num. Return Value Float 406 © 2006 MapInfo Corporation.obj. 1.obj ' represents the graphical object that's attached ' to the first record of the routes table. z. node_num ) object is an Object expression. If the first object is a polyline.obj.. If (ObjectNodeHasZ(routes.5 . 1. node_num is a positive integer value indicating which node to read. MapBasic 8. 1. polyline.ObjectNodeM( ) function Example The following example queries the first graphic object in the table Routes. It is ignored for Multipoint objects (it used for regions and polylines)..obj. OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' .obj. All rights reserved.. then the object is a polyline. Dim i_obj_type As SmallInt. hasM as Logical Open Table "routes" Fetch First From routes ' at this point. 1) ' read m-value End If End If See Also Querying Map Objects. Syntax ObjectNodeM( object. 1. the expression: ' routes.obj. the program queries if the first node in the object has z-coordinates or m-values and queries z-coordinates and m-values of the first node in the polyline. or multipoint object. 1) ' read z-coordinate End If If (ObjectNodeHasM(routes. i_obj_type = ObjectInfo(routes. polygon_num is a positive integer value indicating which polygon or section to query. ObjectInfo( ) function ObjectNodeM( ) function Purpose Returns the m-value of a specific node in a region.. m As Float hasZ.

Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. z = ObjectNodeZ(routes.obj. the expression: ' routes. Syntax ObjectNodeX( object. m As Float Open Table "routes" Fetch First From routes ' at this point. 1) ' read z-coordinate m = ObjectNodeM(routes..obj ' represents the graphical object that's attached ' to the first record of the routes table. this tells MapBasic which of the object's nodes should be queried. z. The ObjectNodeM( ) function supports Multipoint objects and returns the m-value of a specific node in a Multipoint object. If an object does not support m-values. Dim i_obj_type As SmallInt. 1. If the first object is a polyline. node_num ) object is an Object expression. 1) ' read m-value End If See Also Querying Map Objects. All rights reserved. ObjectInfo( ) function ObjectNodeX( ) function Purpose Returns the x-coordinate of a specific node in a region or polyline object. polyline. You can use the ObjectInfo( ) function to determine the number of nodes in an object. or which section (if querying a polyline). then an error is thrown.ObjectNodeX( ) function Description The ObjectNodeM( ) function returns the m-value of a specific node from a region. This specifies which polygon (if querying a region). polygon_num. the program queries z-coordinates and m-values of the first node in the polyline. or multipoint object. The node_num parameter must have a value of one or more.. or an m-value for this node is not defined. Reference Guide © 2006 MapInfo Corporation..obj.obj. should be queried. Example The following example queries the first graphic object in the table Routes. then the object is a polyline. The polygon_num parameter must have a value of one or more. 407 . i_obj_type = ObjectInfo(routes. 1. OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' ..

If the first object is a polyline. Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. i_obj_type = ObjectInfo(routes.obj.and y-coordinates of the first node in the polyline. ObjectGeography( ) function. MapBasic uses a Longitude/Latitude coordinate system. Example The following example queries the first graphic object in the table Routes. ObjectInfo( ) function.. then the object is a polyline. x = ObjectNodeX(routes. node_num is a positive integer value indicating which node to read. The node_num parameter must have a value of one or more. 1) ' read latitude Create Point Into Variable new_pnt (x. the program queries the x.ObjectNodeX( ) function polygon_num is a positive integer value indicating which polygon or section to query. See Set CoordSys statement on page 566 for more information about coordinate systems.. the expression: ' routes.obj.obj ' represents the graphical object that's attached ' to the first record of the routes table. Dim i_obj_type As SmallInt. y) Insert Into routes (obj) Values (new_pnt) End If See Also Alter Object statement. The ObjectNodeX( ) function returns the value in the coordinate system currently in use by MapBasic. y As Float. The corresponding ObjectNodeY( ) function returns the y-coordinate value. Return Value Float Description The ObjectNodeX( ) function returns the x-value of a specific node from a region or polyline object. The polygon_num parameter must have a value of one or more. this tells MapBasic which of the object's nodes should be queried. ObjectNodeY( ) function. 1. then creates a new Point object at the location of the polyline's starting node.. x.. Set CoordSys statement 408 © 2006 MapInfo Corporation. 1. OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' .obj. by default. new_pnt As Object Open Table "routes" Fetch First From routes ' at this point. You can use the ObjectInfo( ) function to determine the number of nodes in an object. The ObjectNodeX( ) function supports Multipoint objects and returns the x-coordinate of a specific node in a Multipoint object. It is ignored for Multipoint objects (it used for regions and polylines). This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried. 1) ' read longitude y = ObjectNodeY(routes. MapBasic 8. All rights reserved.5 .

polygon_num is a positive integer value indicating which polygon or section to query. node_num ) object is an Object expression. or multipoint object. node_num is a positive integer value indicating which node to read. It is ignored for Multipoint objects (it used for regions and polylines). polyline. ObjectGeography( ) function. See ObjectNodeX( ) function on page 407 for more information. See Also Alter Object statement. Syntax ObjectNodeY( object. It is ignored for Multipoint objects (it used for regions and polylines). All rights reserved. Return Value Float Description The ObjectNodeY( ) function returns the y-value of a specific node from a region or polyline object. polygon_num. Syntax ObjectNodeZ( object. node_num ) object is an Object expression. polygon_num. node_num is a positive integer value indicating which node to read Reference Guide © 2006 MapInfo Corporation. Set CoordSys statement ObjectNodeZ( ) function Purpose Returns the z-coordinate of a specific node in a region. Example See ObjectNodeX( ) function on page 407. 409 .ObjectNodeY( ) function ObjectNodeY( ) function Purpose Returns the y-coordinate of a specific node in a region or polyline object. ObjectInfo( ) function. polygon_num is a positive integer value indicating which polygon or section to query.

5 . z. i_obj_type = ObjectInfo(routes. polyline. This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried. If the first object is a polyline. The ObjectNodeZ( ) function supports Multipoint objects and returns the z-coordinate of a specific node in a Multipoint object. then an error is thrown. Example The following example queries the first graphic object in the table Routes. or multipoint object.. OBJ_INFO_TYPE) If i_obj_type = OBJ_PLINE Then ' . ObjectInfo( ) function 410 © 2006 MapInfo Corporation. or Z-value for this node is not defined.obj ' represents the graphical object that's attached ' to the first record of the routes table. If object does not support Z-values.obj...obj. 1. then the object is a polyline. Call the ObjectInfo( ) function to determine the number of polygons or sections in an object. 1) ' read m-value End If See Also Querying Map Objects. m As Float Open Table "routes" Fetch First From routes ' at this point. MapBasic 8. the expression: ' routes. the program queries z-coordinates and m-values of the first node in the polyline. You can use the ObjectInfo( ) function to determine the number of nodes in an object. 1) ' read z-coordinate m = ObjectNodeM(routes. this tells MapBasic which of the object's nodes should be queried. The node_num parameter must have a value of one or more.ObjectNodeZ( ) function Return Value Float Description The ObjectNodeZ( ) function returns the z-value of a specific node from a region. z = ObjectNodeZ(routes.obj. Dim i_obj_type As SmallInt. All rights reserved. 1.. The polygon_num parameter must have a value of one or more.

Only region objects will be checked. By default. All rights reserved. and the Pen Clause to represent the boundary of the regions. the output data is placed into the same table as the input table. Regions will be created in the output table representing any areas of overlap.tab and world. which may cause problems and/or incorrect results in various operations.Objects Check statement Objects Check statement Purpose Checks a given table for various aspects of incorrect data. The Overlap option will check the table for places where regions overlap with other regions. The states. such as combine. By default. or possible incorrect data. Gaps are enclosed areas where no region object currently exists. and split. this is a 28point red pushpin. For any of these problems. An example of this would be the Great Lakes in the World map. most regions abut other regions and share a common boundary. these regions are drawn with solid yellow interiors and thin black boundaries.tab files provided with the sample data are examples of boundary tables. In some cases. Description Objects Check will check the table designated in the From clause for various aspects of bad data which may cause problems or incorrect results with various operations. If the SelfInt option is included. They may also cause incorrect results from various object-processing operations. and areas of overlap and gaps. which Reference Guide © 2006 MapInfo Corporation. Many region tables are designed to be boundary tables. there should also be no gaps between the regions. including the calculation for the area of a region. then the table will be checked for self-intersections. In tables such as these. point objects are created using the style provided by the Symbol Clause. the state of Utah should not overlap with the state of Wyoming). Units is a value of an area. Self-intersections may cause problems with various calculations. boundaries should not overlap (for example. erase outside. In a boundary table. These regions will be created using the Brush Clause to represent the interior of the regions. The region objects will be optionally checked for self-intersections. buffer. If no Into Table clause exists. 411 . The output table can be supplied through the Into Table clause. a point object is created and placed into the output table. Syntax Objects Check From tablename Into Table tablename [ SelfInt [ Symbol Clause] ] [ Overlap [ Pen Clause ] [ Brush Clause ] ] [ Gap Area [ Unit Units ] [ Pen Clause ] [ Brush Clause ] ] ] tablename is a string representing the name of a table. these boundary gaps are legitimate for the data. Clause is an expression. Just as there should be no overlaps between the regions. erase. Where found.

Regions containing spikes will have the spike portion removed. All rights reserved. Any potential gap that is larger than this gap area is discarded and not reported. then the Gap Area value will be interpreted in MapBasic's current area unit.e. Self-intersecting regions in the form of a figure 8 will be changed into a region containing two polygons that touch each other at a single point.0) Gap 100000 Units "sq mi" Pen (1. overlaps. Description The objects in the input tablename are first checked for various data problems and inconsistencies. from problem gap areas. and optionally removes overlaps and gaps between regions. and gaps.Objects Clean statement separate parts of Canada from the USA. It will also use the Overlap keyword and change the default Point and Polygon styles. If the Units sub-clause is not present. rounded rectangles. These gap areas are generally small.5 .28) Overlap Pen (1. objects check from TestFile into table Dumpfile Overlap Selfint Symbol (67.0) Brush (2..2. Most gaps that are data problems occur because adjacent boundaries do not have common boundaries that completely align. MapBasic 8. such as self-intersections. a Gap Area is used. or ellipses). regions.2. such as the Great Lakes. 412 © 2006 MapInfo Corporation. Example This example will run Objects Check on the table called TestFile and store the results in the table called DumpFile. The resulting cleaned object will replace the original input object. The table may be the Selection table. The units that the Gap Area is in is presented by the Units clause.0) Brush (2. Gaps will be presented using the Pen and Brush clauses that follow the Gap keyword. Syntax Objects Clean From tablename [ Overlap ] [ Gap Area [ Unit Units ]] tablename is a string representing the name of a table. these regions are drawn with blue interiors and a thin black boundary.255. Units is a value of an area.16711680. rectangles. All objects to be cleaned must be closed object types (i. By default.0) See Also Objects Enclose statement Objects Clean statement Purpose Cleans the objects from the given table.16776960. To help weed out the legitimate gap areas.

To help weed out the legitimate gap areas. The result does not contain any overlaps. Gaps are enclosed areas where no region object currently exists. then overlapping areas will be removed from regions. Reference Guide © 2006 MapInfo Corporation. In some cases. The units of the Gap Area are indicated by the Units sub-clause. These gap areas are generally small. corresponds to MapInfo Professional's Objects > Combine command. column = expression . which separate parts of Canada from the USA. there should also be no gaps between the regions. All rights reserved. If one object is completely inside another object. and a hole is punched in the containing object. both these boundary gaps and holes are legitimate for the data. expression is an expression used to populate the column. Note: Objects Clean removes the overlap when one object is completely inside another.. An example of this would be the Great Lakes in the World map. Gaps that are found will be removed by combining the area defining the gap to the region with the largest area that touches the gap. In a boundary table. Any potential gap that is larger than this gap area is discarded and not reported. Objects Check statement Objects Combine statement Purpose Combines objects in a table. Objects Disaggregate statement. then the Gap Area value is interpreted in MapBasic's current area unit. Syntax Objects Combine [ Into Target ] [ Data column = expression [ . If the Units sub-clause is not present. most regions abut other regions and share a common boundary. ] ] column is a string representing the name of a column in the table being modified. from problem gap areas. Most gaps that are data problems occur because adjacent boundaries do not have common boundaries that completely align. use the Objects Check statement. This is an exception to the rule of “biggest object wins”. Any gaps that the Objects Check statement flags will be removed with the Objects Clean statement.Objects Combine statement If the Overlap keyword is included. Just as there should be no overlaps between the regions. Example Open Table "STATES.TAB" Interactive Map From STATES Set Map Layer 1 Editable On select * from STATES Objects Clean From Selection Overlap Gap 10 Units "sq m" See Also Create Object statement. a Gap Area is used.. such as the Great Lakes. 413 . The portion of the overlap will be removed from all overlapping regions except the one with the largest area. then the object that is inside remains. To help determine a reasonable Gap Area.

MapBasic stores the hard-coded value in the column of the result object. col_name = Sum( col_name ) 414 © 2006 MapInfo Corporation. Objects involved in the combine operation must either be all closed objects (for example. etc. The column in the result object contains the sum of the column values of all objects being combined. To see a demonstration of the Objects Combine statement. If you include the Into Target clause. and if the selected objects are from the same table as the target object. open MapInfo Professional's MapBasic Window. (For an introduction to data aggregation. lines.5 . and if the selected objects are from a different table than the target object. regions. For an introduction to this operation. The rows corresponding to the selected objects are deleted. If you include the Into Target clause. MapInfo Professional does not delete the selected objects. MapInfo Professional combines the currently-selected objects without involving the current editing target (if there is an editing target). If you omit the Into Target clause. run MapInfo. The optional Into Target clause is only valid if an editing target has been specified (either by the user or through the Set Target statement). or arcs). The following table lists the more common types of column assignments: Expression col_name = col_name col_name = value Description The column contents are not altered. The object produced by the combine operation then replaces the object that had been the editing target. calculating sums or averages of the data values that are associated with the objects being combined. MapBasic 8. assuming the expression is of the correct data type (numeric. You can assign any expression to a column.). All rights reserved. The Objects Combine statement corresponds to MapInfo Professional's Objects > Combine menu item. string. or ellipses) or all linear objects (for example. Optionally. MapInfo Professional combines the currently-selected objects with the current target object. MapInfo Professional deletes the rows corresponding to the selected objects. rectangles. and a new row is added to the table. rounded rectangles. and only if the target consists of one object. containing the object produced by the combine operation. polylines. Mixed closed and linear objects as well as point and text objects are not allowed. see the discussion of the Objects > Combine menu item in the MapInfo Professional Reference.) The Data clause includes a comma-separated list of assignments. and use the Objects > Combine command. see the description of the Objects > Combine operation in the MapInfo Professional Reference. If you include the Into Target clause. Used only for numeric columns. Objects Combine can also perform data aggregation. The Data clause controls data aggregation.Objects Combine statement Description Objects Combine creates an object representing the geographic union of the currently selected objects.

Description If an object contains multiple entities. 415 . col_name = WtAvg( colname. and MapInfo Professional assigns blank values to all of the columns of the new row. averaging all of the col_ name column values. MapBasic assigns blank values to those columns that are not listed in the Data clause. Holes (interior boundaries) will produce solid single polygon Region Reference Guide © 2006 MapInfo Corporation. If the Data clause only includes assignments for some of the columns. If you omit both the Data clause and the Into Target clause. and weighting the average calculation based on the contents of the wt_colname column. If you omit the Data clause entirely. column_name is a string representing the name of a column in the table being modified.. column_name = expression . A Region object will be broken down into some number of region objects. MapInfo Professional performs weighted averaging. depending on the All flag. any multi-part object will be divided into its atomic parts. By default. but you include the Into Target clause. ] name is a string representing the name of a table to store the disaggregated objects. then the Region will produce a series of single polygon Region objects.Objects Disaggregate statement Expression col_name = Avg( col_name ) Description Used only for numeric columns. then MapInfo Professional retains the target object's original column values. The column in the result object contains the average of column values of all objects in the group. then the object produced by the combine operation is stored in a new row. one object for each polygon contained in the original object.. If the All flag is present. Set Target statement Objects Disaggregate statement Purpose Breaks an object into its component parts. Used only for numeric columns. then a new object is created in the output table for each entity. See Also Combine( ) function. wtcolname ) The Data clause can contain an assignment for every column in the table. Syntax Objects Disaggregate [ IntoTable name ] [ All | Collection ] [ Data column_name = expression [ . All rights reserved. expression is an expression used to determine what is placed into the column_name columns.

Rectangles. and Ellipses. and will produce an error. the new Polyline objects will be produced for each section that exists in the input object. if an input Region contains three polygons. Lines. Multiple-section Polyline objects will produce new single-section Polyline objects. Lines. then Holes will be retained in the output objects. then new Region objects will be produced as described above. Polylines. If no Into Table is provided. all other object types. Other object types. then that Polyline will be a new object in the output. Rectangles. If a Region contains a single polygon. one Point object per node from the input Multipoint. For example. If a Collection object contains a Polyline.5 . The functionality above will never produce a Multipoint object. All rights reserved. 416 © 2006 MapInfo Corporation. then that Multipoint will be a new object in the output. it will be passed unchanged to the output. depending on the All switch. the output object will be changed into a Point object containing that node. the currently editable table is used as the output table. This differs from the above functionality since the output Region may contain multiple polygons. Multipoint objects will produce new Point objects.All other object types. Arcs. will be moved to the output unchanged. Collections will be treated recursively. and Ellipses. Multipoints. including Points. then the output will be two Region objects. the output Polyline may contain multiple segments. If the All flag is not present. The input objects are taken from the current selection. and Ellipses will be passed unchanged to the output. it will be passed unchanged to the output. If a Collection object contains a Multipoint. Rounded Rectangles. one Point object for each node in the Mutlipoint. Arcs. If a Collection contains a Region. will not be accepted by the Objects Disaggregate statement. including Points. which are already single component objects. If a Multipoint object contains a single node.Objects Disaggregate statement objects. If the Collection contains a Polyline object. such as Text. Each column assignment can take one of the forms listed in the following table: Assignment col_name = col_name Effect Does not alter the value stored in the column. then that Region will be a new object on output. The Data clause can contain a comma-separated list of column assignments. then new Point objects will be produced. The optional Data clause controls what values are stored in the columns of the target objects. With the Collection keyword. will be passed to the output unchanged. and one of those polygons is a Hole in another polygon. Rectangles. MapBasic 8. The Collection keyword will only break up Collection objects. If a Collection contains a Multipoint. Rounded Rectangles. one of which will contain the hole. Regions. Arcs. If a Polyline object contains a single section. If a Collection object contains a Region. Rounded Rectangles.

If you omit the Data clause entirely. If the Data clause only specifies assignments for some of the columns. Example Open Table "STATES. Syntax Objects Enclose [ Into Table tablename] [ Region ] tablename is a string representing the name of the table you want to place objects in. A new region is created for each enclosed polygonal area.TAB" Interactive Map From STATES Set Map Layer 1 Editable On select * from STATES Objects Disaggregate Into Table STATES See Also Create Object statement Objects Enclose statement Purpose Creates regions that are formed from collections of polylines. Used only for numeric columns. all columns are blanked out of the target objects. and arcs). Description Objects Enclose creates objects representing closures linear objects (lines. Input objects are obtained from the current selection. Unlike the Objects Combine statement. storing zero values in numeric columns and blank values in character columns. the Objects Enclose statement does not remove the original input objects. If the column is a character column.Objects Enclose statement Assignment col_name = value Effect Stores a specific value in the column. Reference Guide © 2006 MapInfo Corporation. the value can be a string. corresponds to MapInfo Professional's Objects > Enclose menu item. All rights reserved. the value can be a number. 417 . reduces the number stored in the column in proportion to how much of the object's area was erased. col_name = Proportion( col_name ) The Data clause can contain an assignment for every column in the table. No data aggregation is done. polylines. If the column is a numeric column. blank values are assigned to those columns that are not listed in the Data clause.

select * from testfile Objects Enclose Into Table dump_file See Also Objects Check statement. ] column_name is a string representing the name of a column in the table being modified. Description The Objects Erase statement erases part of (or all of) the objects that are currently designated as the editing target.. and then performing the Objects Enclose operation. Objects Combine statement Objects Erase statement Purpose Erases any portions of the target object(s) that overlap the selection. corresponds to choosing Objects > Erase. and the Region keyword is not present. column_name = expression . rectangles. Otherwise. The effects are identical to first converting any closed objects to Polyline objects. points. Using the Objects Erase statement is equivalent to choosing MapInfo Professional's Objects > Erase menu item.. All input objects must be linear or closed. If closed objects exist in the selection. All rights reserved. For an introduction to using Objects > Erase. see the discussion of the Objects > Enclose menu item in the MapInfo Professional Reference. The input regions will be converted to Polylines for the purpose of this operation. 418 © 2006 MapInfo Corporation. For an introduction to this operation. then those objects will be ignored. collections. The optional Into Table clause places the objects created by this command into the table. multipoints. and text) will cause the operation to produce an error. The Objects Enclose statement corresponds to MapInfo Professional’s Objects > Enclose menu item. and use the Objects > Combine command. MapBasic 8. Example This will select all the objects in a table called testfile.5 . expression is an expression used to determine what is erased from the column_name columns. and ellipses) to be used as input to the Objects Enclose statement. see the MapInfo Professional Reference. open the MapBasic Window. performs an Objects Enclose and stores the resulting objects in a table called dump_file.e. the output objects are placed in the same table that contains the input objects. Syntax Objects Erase Into Target [ Data column_name = expression [ . and any other objects (i. rounded rectangles.. To see a demonstration of the Objects Enclose statement. run MapInfo Professional.Objects Erase statement The optional Region clause allows closed objects (regions.

Used only for numeric columns. If it is a character column. if it is a numeric column. the Objects Erase statement includes a Data clause. If the Target lies inside cutter objects. and an editing target must exist. the object's column value is reduced by half. The editing target may have been set by the user choosing Objects > Set Target. one or more closed objects (regions. MapBasic assigns blank values to those columns that are not listed in the Data clause. For each Target object. use the Objects Intersect statement. The Data clause can contain a comma-separated list of column assignments. the value can be a string. MapBasic stores blank values in the columns of the target object(s). The optional Data clause controls what values are stored in the columns of the target objects. the Objects Erase statement does not include a Data clause. col_name = value col_name = Proportion( col_name ) The Data clause can contain an assignment for every column in the table. If you omit the Data clause entirely. If the Data clause only specifies assignments for some of the columns. one object will be produced for that portion of the target that lies outside all cutter objects. and one or more objects have been selected. MapBasic stores a specific value in the column. the value can be a number. and Med_Inc_80). Before you call Objects Erase. This operation assigns the string “area remaining” to the State_Name column and specifies that the Pop_1990 column Reference Guide © 2006 MapInfo Corporation. which specifies expressions for three columns (State_Name.Objects Erase statement Objects Erase erases any parts of the target objects that overlap the currently selected objects. storing zero values in numeric columns and blank values in character columns. Pop_1990. Each column assignment can take one of the forms listed in the following table: Assignment col_name = col_name Effect MapBasic does not alter the value stored in the column. or it may have been set by the MapBasic Set Target statement. then no object is produced for output. So. Example In the following example. 419 . All rights reserved. rectangles. MapBasic blanks out all columns of the target object. MapBasic reduces the number stored in the column in proportion to how much of the object's area was erased. As a result. or ellipses) must be selected. Objects Erase Into Target In the next example. if the operation erases half of an area's object. rounded rectangles. To erase only the parts of the target objects that do not overlap the selection. This example assumes that one or more target objects have been designated.

Description The Objects Intersect statement erases part or all of the object(s) currently designated as the editing target. see the MapInfo Professional Reference. Using the Objects Intersect statement is equivalent to choosing MapInfo Professional's Objects > Erase Outside menu item. expression is an expression used to determine what is erased from the column_name columns. The optional Data clause controls what values are stored in the columns of the target objects. 420 © 2006 MapInfo Corporation. For an introduction to using Objects > Erase Outside. Each column assignment can take one of the forms listed in the following table: Assignment col_name = col_name Effect MapBasic does not alter the value stored in the column. Objects Intersect statement Objects Intersect statement Purpose Erases any portions of the target object(s) that do not overlap the selection. Objects Erase Into Target Data State_Name = "area remaining"... Syntax Objects Intersect Into Target [ Data column_name = expression [ . Med_Inc_80 = Med_Inc_80 See Also Erase( ) function. MapBasic 8. ] ] column_name is a string representing the name of a column in the table being modified. corresponds to choosing Objects > Erase Outside. Pop_1990 = Proportion( Pop_1990 ). The target objects' other columns are blanked out. The Data clause can contain a comma-separated list of column assignments. All rights reserved.5 .Objects Intersect statement should be reduced in proportion to the amount of the object that is erased. column_name = expression . The Med_Inc_80 column retains the value it had before the Objects Erase statement.

For example. the value can be a number. The parts of the target that lie outside all cutter objects will be discarded. then three new objects will be created. MapBasic reduces the number stored in the column in proportion to how much of the object's area was erased. while the Objects Erase statement erases the parts of the target object. Example Objects Intersect Into Target Data Field2=Proportion(Field2) See Also Create Object statement. Thus. If the Data clause only specifies assignments for some of the columns. If the column is a character column. Used only for numeric columns. storing zero values in numeric columns and blank values in character columns. MapBasic assigns blank values to those columns that are not listed in the Data clause. the value can be a string. col_name = Proportion( col_name ) The Data clause can contain an assignment for every column in the table. if a target object is intersected by three cutter objects. Objects Erase statement Reference Guide © 2006 MapInfo Corporation. The Objects Intersect statement is very similar to the Objects Erase statement. if the column is a numeric column. MapBasic blanks out all columns of the target objects. 421 . All rights reserved. if the operation erases half of the area of an object. If you omit the Data clause entirely. the object's column value is reduced by half.Objects Intersect statement Assignment col_name = value Effect MapBasic stores a specific value in the column. Overlap( ) function. see Objects Erase statement on page 418. For more information. a new object is created for each area that intersects a cutter object. with one important difference: Objects Intersect erases the parts of the target objects(s) that do not overlap the current selection. For each Target object.

the Cartesian calculations are used regardless of the Type setting.5 . The distance is in the units specified by unit parameter. Syntax Objects Move Angle angle Distance distance [ Units unit ] [ Type { Spherical | Cartesian }] angle is a value representing the angle to move the selected object. This is because you are picking one offset delta in degrees. If the coordinate system is Lat/Long. since the data associated with the original source objects is unchanged. but the area of the object will change. MapBasic 8. If the Units clause is not present. If you move an object that is in Lat/Long. If Cartesian is specified. distance is a number representing the distance to move the selected object. and then that value is converted from the input units into the coordinate system's units. Description Objects Move moves the objects within the input table. If the data is in a Latitude/Longitude Projection. to change this unit. There are some considerations for Spherical measurements that do not hold for Cartesian measurements. use the Set Distance Units statement. and offset at a distance given by the distance parameter. and the actual measured distance for a degree is different at different locations. The source objects are obtained from the current selection. The object is moved in the direction represented by angle. the actual offset delta is calculated at some fixed point on the object (for example. the center of the bounding box). By default. unit is the distance unit of distance. If the data is in a NonEarth Projection. then Spherical calculations are used regardless of the Type setting. No data aggregation is performed or necessary. then the calculation is done by considering the data to be projected to a flat surface and distances are measured using Cartesian distance calculations. The optional Type sub-clause lets you specify the type of distance calculation used to create the offset. then the calculation is done by mapping the data into a Latitude/Longitude On Earth projection and using distance measured using Spherical distance calculations. The resulting objects replace the input objects. then the current distance unit is the default. the conversion to degrees uses 422 © 2006 MapInfo Corporation.Objects Move statement Objects Move statement Purpose Moves the objects obtained from the current selection within the input table. measured from the positive X-axis (east) with positive angles being counterclockwise. MapBasic uses miles as the distance unit. If Spherical type is specified. If the Type sub-clause is not present. For the Offset functions. then the Spherical distance calculation type is used. the shape of the object remains the same. All rights reserved. if present.

]] intotable is a string representing the table that the new values are copied to. angle is a value representing the angle which to offset the selected objects. the base table of the selection).Objects Offset statement the fixed point. and offset at a distance given by the distance parameter. column = expression . By default. All rights reserved. column is a string representing the column on which to perform the offset. The source objects are obtained from the current selection. use the Set Distance Units statement. Syntax Objects Offset [ Into Table intotable ] Angle angle Distance distance [ Units unit ] [ Type { Spherical | Cartesian }] [ Data column = expression [. Otherwise. MapBasic uses miles as the distance unit. expression is an expression to calculate the offset for the column. If the Units clause is not present. 423 .e.. the objects are placed into the same table as the input objects are obtained from (i. to change this unit. distance is a number representing the distance to offset the selected objects... measured from the positive X-axis (east) with positive angles being counterclockwise. Description Objects Offset makes a new copy of objects offset from the original source objects. obtained from the current selection. 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 Objects Move Angle 45 Distance 100 Units "mi" Type Spherical See Also Objects Offset statement Objects Offset statement Purpose Copies objects. offset from the original objects. Reference Guide © 2006 MapInfo Corporation. The resulting objects are placed in the intotable. unit is the distance unit of distance. if the Into clause is present. The object is moved in the direction represented by angle. then the current distance unit is the default. The distance is in the units specified by the unit parameter.

and then that value is converted from the input units into the coordinate system's units. the shape of the object remains the same. For more information. If Spherical type is specified. the conversion to degrees uses the fixed point. The actual converted distance measurement could vary at different locations on the object. then the Spherical distance calculation type is used. The distance from the input object and the new offset object is only guaranteed to be exact at the single fixed point used. the Cartesian calculations are used regardless of the Type setting. one or more objects must be selected. the actual offset delta is calculated at some fixed point on the object (for example. If the coordinate system is Lat/Long. corresponds to choosing Objects > Overlay Nodes. then the calculation is done by mapping the data into a Latitude/Longitude On Earth projection and using distance measured using Spherical distance calculations. For the Offset functions. There are some considerations for Spherical measurements that do not hold for Cartesian measurements. The editing target may have been set by the user choosing Objects > Set Target. All rights reserved. If the data is in a Latitude/Longitude Projection. Syntax Objects Overlay Into Target Description Before you call Objects Overlay. Example Objects Offset Into Table c:\temp\table1. MapBasic 8. If Cartesian is specified. the application performs data aggregation. If you specify a Data clause. then Spherical calculations are used regardless of the Type setting. see the discussion of Overlay Nodes in the MapInfo Professional Reference. then the calculation is done by considering the data to be projected to a flat surface and distances are measured using Cartesian distance calculations. If the data is in a NonEarth Projection. 424 © 2006 MapInfo Corporation.5 . the center of the bounding box). or it may have been set by the MapBasic Set Target statement. If you move an object that is in Lat/Long. and the actual measured distance for a degree is different at different locations. This is because you are picking one offset delta in degrees. and an editing target must exist. but the area of the object will change. If the Type sub-clause is not present.tbl Angle 45 Distance 100 Units "mi" Type Spherical See Also Offset( ) function Objects Overlay statement Purpose Adds nodes to the target objects at any places where the target objects intersect the currently selected objects.Objects Overlay statement The optional Type sub-clause lets you specify the type of distance calculation used to create the offset.

. The Data clause can contain an assignment for every column in the table. Reference Guide © 2006 MapInfo Corporation. If the column is a character column the value can be a string. expression is an expression which is used to assign values to column_name. column_name is a string representing the name of the column where the new values are stored.. then two new single section polyline objects are created in the output table name. the operation is cancelled and an error message is displayed. The optional Data clause controls what values are stored in the columns of the output objects. Syntax Objects Pline Split At Node index [ Into Table name ] [ Data column_name = expression [ . If Node is a start or end node for the polyline. column_name = expression . name is a string representing the name of the table to hold the new objects. if the column is a numeric column. Each column assignment can take one of the forms listed in the following table: Assignment col_name = col_name col_name = value Effect Does not alter the value stored in the column. Stores a specific value in the column. ]] index is an integer of the index number of the node to split. The Node index should be a valid MapBasic index for the polyline to be split. If the Data clause specifies assignments for only some of the columns. Set Target statement Objects Pline statement Purpose Splits a single section polyline into two polylines. 425 . all columns are blanked out of the target objects. blank values are assigned to those columns that are not listed in the Data clause. The Data clause can contain a comma-delimited list of column assignments. the value can be a number. Description If an object is a single section polyline. All rights reserved. If you omit the Data clause entirely. storing zero values in numeric columns and blank values in character columns.Objects Pline statement See Also OverlayNodes( ) function.

spacing_distance is a number representing the minimum distance a series of nodes in the same object can be to each other without being removed. bend_distance is a number representing the co-linear tolerance of a series of nodes.e. 426 © 2006 MapInfo Corporation.Continent=Continent.. The unchanged values from each record of the selected polyline are inserted into the new records for the split polyline.Numeric_code=Numeric_ code. ObjectNodeX( ) function.5 . Objects Pline Split At Node 12 Into Table WORLD Data Country=Country. regions.Pop_Male=Pop_Male. or ellipses). unit_string is a string representing the distance units to be used. rounded rectangles. All of the objects to be cleaned must either be all linear (i.ISO_3=ISO_3. Syntax Objects Snap From tablename [ Tolerance [ Node node_distance ][ Vector vector_distance ] [ Units unit_string] ] [ Thin [ Bend bend_distance ][ Distance spacing_distance ] [ Units unit_string ]] [ Cull Area cull_area [ Units unit_string ]]] tablename is a string representing the name of the table of the objects to be checked. Mixed linear and closed objects cannot be cleaned in one operation. the selected polyline is split at the specified node (node index of 12). unit_string is a string representing the area units to be used. polylines and arcs) or all closed (i.ISO_2=ISO_2.FIPS=FIPS.Pop_Grw_Rt=Pop_ Grw_Rt.Pop_1994=Pop_1994.Pop_Fem=Pop_Fem. including snapping nodes from different objects that are close to each other into the same location and generalization/thinning..Capital=Capital. node_distance is a number representing a radius around the end points nodes of a polyline. The table may be the Selection table.. vector_distance is a number representing a radius used for internal nodes of polylines. MapBasic 8. and optionally performs various topology-related operations on the objects.Objects Snap statement Example In the following partial example. Objects Disaggregate statement Objects Snap statement Purpose Cleans the objects from the given table. All rights reserved. rectangles. ObjectNodeY( ) function.. See Also ObjectLen( ) function.e. and an error will result. cull_area is a number representing the threshold area within which polygons are culled.

connect all of the nodes in a triangle. The Node and Vector Tolerances values snap nodes from different objects together. use the Set Distance Units statement. If this distance is less than the Bend tolerance. then the three nodes are considered co-linear. except it is used only for internal (non-end point) nodes of a polyline. If the Units sub-clause is not present. and the second node is removed from the object. The Units sub-clause of Thin lets you specify a distance measurement name (such as “km” for kilometers) to apply to the Bend and Distance values. The resulting cleaned object replaces the original input object. then one or both of the nodes will be moved such that they will be in the same location (i. The Distance tolerance is used to eliminate nodes within the same object that are close to each other. 427 . Measure the perpendicular distance from the second node to the line connecting the first and third nodes. Removal of overlaps generally consists of cutting the overlapping portion out of one of the objects. The Units sub-clause of Tolerances lets you specify a distance measurement name (such as “km” for kilometers) to apply to the Node and Vector values.Objects Snap statement Description The objects from the input tablename are checked for various data problems and inconsistencies.. One polygon represents the non-overlapping portion. The Node tolerance is ignored for Region objects. If any overlaps exist between the objects they are removed. only the Vector tolerance is used. while leaving it in the other object. MapBasic uses miles as the distance units. then one of the nodes can be removed. If the Units sub-clause is not present. For Region objects. The Bend and Distance values can be used to help thin or generalize the input objects. Measure the distance between two successive nodes in an object. Reference Guide © 2006 MapInfo Corporation. and it is applied to all nodes in the object. For Polyline objects. Note that for Region objects. Self-intersecting regions in the form of a figure 8 will be changed into a region containing two polygons that touch each other at a single point. All rights reserved. The Node tolerance is a radius around the end point nodes of a polyline. If the distance between them is less than the Distance tolerance. Its purpose is the same as the Node tolerance. By default. there is no explicit concept of end point nodes. such as self-intersections. to change this unit. Given three nodes. This reduces the number of nodes used in the object while maintaining the general shape of the object. they will be snapped together). then the Bend and Distance values are interpreted in MapBasic's current distance unit. If there are nodes from other objects within this radius. the Node tolerance must be greater than or equal to the Vector tolerance. and can be used to eliminate small overlaps and gaps between objects. since the nodes form a closed loop. The region that contains the originally overlapping section consists of multiple polygons. The Vector tolerance is a radius used for internal nodes of polylines. The Bend tolerance is used to control how co-linear a series of nodes can be. and a separate polygon represents each overlapping section. then the Node and Vector values are interpreted in MapBasic's current distance unit. Regions containing spikes have the spike portion removed.e.

Before you call Objects Split. A length and area calculation in Longitude/Latitude calculated using the Cartesian method is not mathematically precise. ] column_name is a string representing the name of the column where the new values are stored. Please keep in mind the coordinate system that your data is in. rectangles.5 . The Units sub-clause of Cull lets you specify an area measurement name (such as “sq km” for square kilometers) to apply to the Area value. using the currently-selected objects as a “cookie cutter”.Objects Split statement The Cull Area value is used to eliminate polygons from regions that are smaller than the threshold area. and an editing target must exist. All rights reserved. corresponds to choosing Objects > Split... Description Use the Objects Split statement to split each of the target objects into multiple objects. 428 © 2006 MapInfo Corporation. MapBasic 8. or ellipses) must be selected. the type of measurement used is always Cartesian. then the Area value is interpreted in MapBasic's current area unit. Note: For all of the distance and area values mentioned above. see the MapInfo Professional Reference. The editing target may have been set by the user choosing Objects > Set Target. If the Units sub-clause is not present.5 Distance 1 Units "mi" Cull Area 10 Units "sq mi" See Also Create Object statement. or it may have been set by the MapBasic Set Target statement. to change this unit. Syntax Objects Split Into Target [ Data column_name = expression [ . column_name = expression . Example Open Table "STATES. By default. MapBasic uses square miles as the area unit. Using Objects Split is equivalent to choosing MapInfo Professional's Objects > Split menu item.TAB" Interactive Map From STATES Set Map Layer 1 Editable On select * from STATES Objects Snap From Selection Tolerance Node 3 Vector 3 Units "mi" Thin Bend 0. use the Set Area Units statement. rounded rectangles. expression is an expression which is used to assign values to column_name. one or more closed objects (regions. Overlap( ) function Objects Split statement Purpose Splits target objects. For more information on split operations. Ensure that you are working in a suitable coordinate system (a Cartesian system) before applying the tolerance values.

This first part of the Data clause assigns the string “sub-division” to the State_Name column.Objects Split statement For each target object. If the column is a character column. The next part of the Data clause specifies that Reference Guide © 2006 MapInfo Corporation. As a result. if the column is a numeric column. MapBasic stores a specific value in the column. Used only for numeric columns. which specifies expressions for three columns (State_Name. The Data clause can contain a comma-separated list of column assignments. each object resulting from the split operation retains the original column value. If you omit the Data clause entirely. the statement includes a Data clause. MapBasic stores blank values in the columns of the target object(s). For example. MapInfo Professional divides the original target object's column value among the graphical objects resulting from the split. All rights reserved. a single object will be created for all parts of the target object that lie outside all cutter objects. col_name = value col_name = Proportion( col_name ) The Data clause can contain an assignment for every column in the table. If the Data clause only specifies assignments for some of the columns. if a target object is intersected by three cutter objects. a new object is created for each area that intersects a cutter object. 429 . MapBasic assigns blank values to those columns that are not listed in the Data clause. Objects Split Into Target In the next example. the value can be a number. Example In the following example. The optional Data clause controls what values are stored in the columns of the target objects. the value can be a string. with larger objects receiving larger portions of the numeric values. Each object resulting from the split operation retains the specified value. Each column assignment can take one of the forms listed in the following table: Assignment col_name = col_name Effect MapBasic does not alter the value stored in the column. then three new objects will be created. MapBasic blanks out all columns of the target objects. Pop_1990. In addition. “sub-division” will be stored in the State_ Name column of each object produced by the split. and Med_Inc_80). as a result. This is equivalent to performing both an Objects Erase statement and an Objects Intersect statement (Objects > Erase Outside). the Objects Split statement does not include a Data clause. storing zero values in numeric columns and blank values in character columns. Each object receives “part of” the original column value.

the center of the bounding box). angle is the angle to offset the object. distance is a number representing the distance to offset the object. Pop_1990 = Proportion( Pop_1990 ). The units string. For NonEarth. Return Value Object Description Offset( ) 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). units is a string representing the unit in which to measure distance. There are some considerations for Spherical measurements that do not hold for Cartesian measurements. Med_Inc_80 = Med_Inc_80 See Also Alter Object statement Offset( ) function Purpose Returns a copy of the input object offset by the specified distance and angle. This is because you are picking one offset delta in degrees. Syntax Offset( object. distance. The distance type used is Spherical unless the Coordinate System is NonEarth. angle. Objects Split Into Target Data State_Name = "sub-division". but the area of the object will change. For the Offset functions.Offset( ) function the target object's original Pop_1990 value should be divided among the objects produced by the split. The coordinate system used is the coordinate system of the input object. the actual offset delta is calculated at some fixed point on the object (for example. If the coordinate system is Lat/Long. similar to that used for the ObjectLen( ) function or Perimeter( ) function. is the unit for the distance value. Cartesian distance type is automatically used. and then that value is converted from the input units into the coordinate system's units. The third part of the Data clause specifies that each of the new objects should retain the original value from the Med_Inc_80 column. All rights reserved. the conversion to degrees uses 430 © 2006 MapInfo Corporation. the shape of the object remains the same. and the actual measured distance for a degree is different at different locations. units ) object is the object being offset. MapBasic 8.5 . If you move an object that is in Lat/Long.

The units string. There are some considerations for Spherical measurements that do not hold for Cartesian measurements. the conversion to degrees uses the fixed point. and the actual measured distance for a degree is different at different locations.OffsetXY( ) function the fixed point. and then that value is converted from the input units into the coordinate system's units. 431 . If the coordinate system is Lat/Long. The distance from the input object and the new offset object is only guaranteed to be exact at the single fixed point used. the Cartesian distance type is automatically used. xoffset and yoffset are numbers representing the distance along the x and y axes to offset the object. Syntax OffsetXY( object. but the area of the object will change. If you move an object that is in Lat/Long. 100. OffsetXY( ) function OffsetXY( ) function Purpose Returns a copy of the input object offset by the specified X and Y offset values. The actual converted distance measurement could vary at different locations on the object. the center of the bounding box). The coordinate system used is the coordinate system of the input object. The distance from the input object and the new offset object is only guaranteed to be exact at the single fixed point used. the actual offset delta is calculated at some fixed point on the object (for example. The distance type used is Spherical unless the coordinate system is NonEarth. Return Value Object Description OffsetXY( ) 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. This is because you are picking one offset delta in degrees. Reference Guide © 2006 MapInfo Corporation. similar to that used for the ObjectLen( ) function or Perimeter( ) function. For NonEarth. Example Offset(Rect. the shape of the object remains the same. All rights reserved. "mi") See Also Objects Offset statement. units is a string representing the unit in which to measure distance. For the Offset functions. 45. The actual converted distance measurement could vary at different locations on the object. units ) object is the object being offset. is the unit for the distance values. xoffset. yoffset.

warn the user about the error condition. Exit Sub statement or End Program statement) immediately before the error handler's label. use a Resume statement to resume program execution.OnError statement Example OffsetXY(Rect. if the application generates an error. See the example below. If an error occurs while there is no error-handling routine. MapBasic jumps to the label line specified. Restrictions You cannot issue an OnError statement through the MapBasic window. -22. Each error handler is local to a particular function or procedure. An OnError Goto label statement enables an error-handling routine. then halts the application. 92. The statements following the label presumably correct the error condition. OnError is a single word. or both. Following such an OnError statement. MapBasic displays an error dialog box. Once you have inserted error-handling statements in your program. (An error-handler is a group of statements executed in the event of an error). or disables a previously enabled error-handler. An OnError Goto 0 statement disables the current error-handling routine. you may need to place a flowcontrol statement (for example. Within the error-handling routine. "mi") See Also Offset( ) function OnError statement Purpose Enables an error-handling routine. MapBasic 8. Syntax OnError Goto{ label | 0 } label is a string representing a label within the same procedure or function. Thus.5 . All rights reserved. a sub procedure can define an error handler by issuing a statement such as: OnError Goto recover 432 © 2006 MapInfo Corporation. Description The OnError statement either enables an error-handling routine. BASIC programmers should note that in the MapBasic syntax. but it does not prevent MapBasic from calling the error handler in the event of an error. This prevents the program from unintentionally “falling through” to the error handling statements.

OnError statement (assuming that the same procedure contains a label called “recover” ). With this arrangement. no Map used. after executing the above OnError statement." Map From states Resume after_mapfrom See Also Err( ) function." Resume after_mapfrom no_cities: Note "City data not available.. Example OnError GoTo no_states Open Table "states" OnError GoTo no_cities Open Table "cities" Map From cities. Resume statement Reference Guide © 2006 MapInfo Corporation.. All rights reserved. If.. Error$( ) function. the procedure issues a Call statement to call another sub procedure.. the “recover” error handler is suspended until the program returns from the Call statement.. This is because each label (for example. “recover”) is local to a specific procedure or function. Note: If an error occurs within an error-handling routine. each function and each sub procedure can have its own error handling. 433 . states after_mapfrom: OnError GoTo 0 ' ' . Error statement. ' End Program no_states: Note "Could not open table States.. your MapBasic program halts.

name_string is a string representing the user name for an Envinsa or MapMarker installation. the Set Connection Isogram statement. That is. the dialog box appears if the authentication fails. With Interactive specified as On. If the service is Geocode and no service provider is specified. The Into variable keywords are required as var_name is the variable that holds the returned connection number that is then passed to other statements. URLString must be a valid URL to a routing service if you are specifying Isogram. Envinsa is assumed. such as the Set Connection Geocode statement. no dialog box is displayed and the command fails if the authentication fails.5 . The following example opens a geocoding connection without Interactive specified. if the Interactive keyword is not used at all. the Geocode statement. Each statement must specify a service and provider to which the connection is being established. pwd_string is a string representing the password corresponding to user_name. Examples Note: All examples without the keyword MapMarker assume Envinsa. var_name is a string representing the variable which will hold the returned connection number. it is the same as Interactive Off. All rights reserved. 434 © 2006 MapInfo Corporation. Since the Isogram service is only provided by Envinsa no provider can be specified. The default for the command is Interactive Off. if Interactive is specified. it is equivalent to Interactive On.Open Connection statement Open Connection statement Purpose Creates a connection to an external geocode or Isogram service provided by a MapMarker or Envinsa server. Interactive determines whether a username/password dialog box is shown if and only if the credentials passed in for authentication are not adequate. MapBasic 8. and the Create Object Isogram statement. Interactive is set to Off by default. Description The Open Connection statement creates a connection to a Geocode or Isogram service. With Interactive specified to Off. or to a geocoding service if you are specifying Geocode. Syntax Open Connection Service Geocode [ MapMarker | Envinsa ] | Isogram URL URLstring [ User name_string [ Password pwd_string ] ] [ Interactive [ On | Off ] ] into variable var_name URLString is a string representing a valid URL. However.

All rights reserved. Set Connection Geocode statement. Syntax Open File filespec [ For { Input | Output | Append | Random | Binary } ] [ Access { Read | Write | Read Write } ] As [ # ] filenum [ Len = recordlength ] [ ByteOrder { LOWHIGH | HIGHLOW } ] [ CharSet char_set ] filespec is a string representing the name of the file to be opened. applies only to Random access. Open Connection Into Variable CnctNum Service Geocode URL "http:// EnvinsaServices/LocationUtility/services/LocationUtility" Interactive On This example opens a geocode connection with a server that requires authentication. including any end-of-line markers used. Set Connection Isogram statement Open File statement Purpose Opens a file for input/output.Open File statement Open Connection Into Variable CnctNum Service Geocode URL "http:// EnvinsaServices/LocationUtility/services/LocationUtility" This example opens a geocode connection and specifies Interactive as On. char_set is the name of a character set. dim baseURLVariable as String baseURLVariable = "http://EnvinsaServices/” Open Connection Service Geocode URL baseURLVariable + "LocationUtility/ services/LocationUtility" User "geocodeuser" Password "GeoMe" Into Variable CnctNum This example opens an Isogram connection with a server that requires authentication. 435 . this number is used in subsequent operations (for example. Reference Guide © 2006 MapInfo Corporation. filenum is an integer number to associate with the open file. recordlength identifies the number of characters per record. Get statement or Put statement). dim baseURLVariable as String baseURLVariable = "http://EnvinsaServices/” Open Connection Service IsoGram URL baseURLVariable + "Route/services/ Route" User "isogramuser" Password "ISOMe" Into Variable CnctNum See Also Close Connection statement. see CharSet clause on page 125.

All rights reserved. there is an important distinction between files and tables. Binary files cannot be displayed or printed directly. Fetch statement. such as a carriage-return line-feed sequence. If you omit the For clause. Input # statement. Write to the file. Output. Put statement. one line is 55 characters long. Open Table statement. you can use the Access clause to specify whether you intend to Read from the file. If you specify the For Output clause or the For Append clause. by specifying the clause: For Random. you can read from the file by issuing an Input # statement and a Line Input # statement. After opening a file in Random mode. however. If you specify the For Input clause. The recordlength value should include any end-of-line designator. every line is 80 characters long).Open File statement Restrictions You cannot issue an Open File statement through the MapBasic window. Random. Print # statement). or Binary. or Append. if you specify For Output.). you can write to the file by issuing a Print # statement and a Write # statement. Do not specify a Len clause for files opened in any of the Sequential modes. MapBasic provides one set of statements for using tables (for example. and the next is 72 characters long. conversely. you should specify a Sequential mode: Input. MapBasic 8. Open File. Random File I/O If the text file you are going to read is fixed-length (for example. etc. Storing numerical data in a Binary file is more compact than storing Binary data in a text file. use the Get statement and the Put statement to read from. If you specify For Input. The For clause specifies what type of file i/o to perform: Sequential.5 . so that MapBasic can read information from and/or write information to the file. and converts from binary values when reading. In MapBasic. Description The Open File statement opens a file. 436 © 2006 MapInfo Corporation. the Access clause may only specify Read. When using Random mode. or do both (Read Write). Each type of i/o is described below. the file. Binary File I/O In Binary access. and write to. as can text files. you must provide a Len = recordlength clause to specify the record length. When you open a file in Random mode. you can access the file in Random mode. Sequential File I/O If you are going to read a text file that is variable-length (for example. the file is opened in Random mode. and Select statement) and another set of statements for using other files in general (for example. the Access clause may only specify Write. MapBasic converts MapBasic variables to binary values when writing. Get statement.

such as “WindowsLatin1”. use the Get statement and the Put statement to read from. or do both (Read Write). After opening a file in Binary mode. The char_set parameter should be a string constant. Syntax Open Report reportfilespec reportfilespec is a string representing a full path and file name for an existing report file. specify the clause: For Binary. MapBasic simply uses the byte-order scheme that is “native” to that platform. and write to. or Random modes. If you open a file for Random or Binary access. CharSet clause Open Report statement Purpose Loads a report into the Crystal Report Designer module. the ByteOrder clause specifies how numbers are stored within the file. See Also Create Report From Table statement Reference Guide © 2006 MapInfo Corporation. Do not specify a Len clause or a CharSet clause for files opened in Binary mode.bin" For BINARY As #3 See Also Close File statement.txt" For INPUT As #1 Open File "cydata. If your application only runs on one hardware platform. If you omit the CharSet clause.Open Report statement To open a file in Binary mode. Controlling How the File Is Interpreted The CharSet clause specifies a character set. Write # statement. Put statement. All rights reserved. When using Binary mode. you do not need to be concerned with byte order. See CharSet clause on page 125 for more information. Output. Print # statement. the file. and you need to transport the files across multiple hardware platforms. However. you may need to use the ByteOrder clause. Input # statement. Write to the file. Get statement. MapInfo Professional uses the default character set for the hardware platform that is in use at run-time. Open Table statement. you can use the Access clause to specify whether you intend to Read from the file. Note that the CharSet clause only applies to files opened in Input.txt" For RANDOM As #2 Len=42 Open File "czdata. EOF( ) function. 437 . if you intend to read and write binary files. Examples Open File "cxdata.

A table must be opened before MapInfo Professional can process that table in any way. VMDefault treats GRD as Raster or Grid depending on existence of RasterStyle 6 1 tag in TAB file. use the Register Table statement and the Open File statement. VMGrid treats all VM GRD files as Grid Layers when opened. the File > Close dialog box). the table will not appear in any dialog boxes that display lists of open tables (for example. All rights reserved. The effect is comparable to the effect of an enduser choosing File > Open and selecting a table to open. The Open Table statement only applies to MapInfo tables. If the statement includes the Hide clause. Opening a table under an alias does not have the effect of permanently renaming the table. Applies to Access tables only. Description The Open Table statement opens an existing table. Note: The name of the file to be opened (specified by the filespec parameter) must correspond to a table which already exists. If the statement includes an As clause. VMRaster treats all VM GRD files as Raster Layers when opened.5 . MapInfo Professional opens the table under the “alias” table name indicated by the tablename parameter. use the Create Table statement. the user is not allowed to edit the table. tablename is a string representing an “alias” name by which the table should be identified. rather than the permanent table name. MapBasic 8. such as the list that appears when a user chooses File > Close. Use the Hide clause if you need to open a table that should remain hidden to the user. subsequent MapBasic table operations (for example. rather than by the actual table name. to use files that are in other formats. Furthermore. 438 © 2006 MapInfo Corporation. to create a new table from scratch. An alias table name remains in effect until the table is closed. If the statement includes the ReadOnly clause. This affects the way the table name appears in lists. a Close Table statement) must refer to the alias table name.Open Table statement Open Table statement Purpose Opens a MapInfo Professional table for input/output. to be specified when database security is turned on. Syntax Open [ [ [ Table filename [ As tablename ] Hide ] [ ReadOnly ] [ Interactive ] [ Password pwd ] NoIndex ] [ View Automatic ] [ DenyWrite ] VMGrid | VMRaster | VMDefault ] filename is a string which specifies which MapInfo table to open. pwd is a string representing the database-level password for the database. when an Open Table statement specifies an alias table name.

TAB”). If it is specified. and an Open Table As statement tries to re-open the same table under a new name. The table simply remains open under its current name. TAB_INFO_NAME) to determine the name with which MapInfo Professional opened the table. issue the function call TableInfo(0. the MapInfo index will not be re-built for an MS Access table when opened. to avoid conflicts. DenyWrite is an optional clause for MS Access tables only. MapInfo Professional opens the table under its default name (“Sites”). If an application issues an Open Table statement to open the second Sites table. MapBasic does not generate an error code. or displays a dialog box to let the user select a special table name. Attempting to open a table that is already open If a table is already open. When the user (or an application) opens the first Sites table. “C:\2006\SITES. and then an Open Table statement tries to re-open that table without specifying a new name. If View Automatic is present. 439 . Regardless of whether the Open Table statement specifies the Interactive keyword.TAB. workspace or application file associated with a hotlink object to launch in the currently running instance of MapInfo Professional or start a new instance if none is running. if a table is already open. The Interactive keyword is useful in situations where you do not know the location of the user's files. the Open Table command will fail. then displays the table in a Map window. A single table may not be open under two different names simultaneously. or open a browser. All rights reserved. Attempting to open two tables that have the same name MapInfo Professional can open two separate tables that have the same name. View Automatic is an optional clause to the Open Table statement that allows the MapInfo table.” Reference Guide © 2006 MapInfo Corporation. after opening the table. “Sites_2”) to distinguish it from the first table. Alternately. Because the Open Table statement uses an As clause to open the table under an alias (USA). if the Open Table statement includes the Interactive clause. For example. other users will not be able to edit the table. Depending on whether the Open Table statement includes the Interactive keyword. If another user already has read-write access to the table. However. “C:\2005\SITES. MapInfo Professional displays a dialog box to let the user select the alternate name.Open Table statement The optional Interactive keyword tells MapBasic to prompt the user to locate the table if it is not found at the specified path. MapInfo Professional needs to open the second table under a special name. Following an Open Table statement. MapInfo Professional automatically opens the second table under a modified name (for example. open a new mapper. the result is that a table may be opened under a non-default name. This is especially useful with the HotLinks feature. In such cases. a user might keep two copies of a table called “Sites”. one copy in a directory called 2006 (for example. perhaps newer copy of the table in a different directory (for example. If the statement includes the NoIndex keyword. Example The following example opens the table STATES.TAB”) and another. MapBasic generates an error code. MapBasic either assigns the special table name automatically. the Map window's title bar will say “USA Map” rather than “States Map. MapInfo Professional will either add it to an existing mapper.

The TableInfo( ) function call returns the alias under which the “C:STATES. Window Name MapBasic Window Description The MapBasic window. Statistics 440 © 2006 MapInfo Corporation. MapBasic 8. Description The Open Window statement displays an MapInfo Professional window. Ruler) or window code (for example. TAB_INFO_NAME) Browse * From s_tab Map From tab See Also Close Table statement.TAB” under a special alias (for example. TableInfo( ) function.TAB” table was opened. Create Table statement. Include "MAPBASIC. Open Window Statistics The window_name parameter should be one of the window names from the table below. Syntax Open Window window_name window_name is a string representing a window name (for example. Update statement Open Window statement Purpose Opens or displays a window. In the unlikely event that a separate table by the same name (States) is already open when you run the program below.DEF (WIN_MAPBASIC). Fetch statement. The Statistics window (WIN_STATISTICS).5 . as if the user had chosen Options > Show Statistics Window. Insert statement. You also can refer to this window by its define code from MAPBASIC. Delete statement.DEF" Dim s_tab As String Open Table "C:states" s_tab = TableInfo(0. the following statement displays the statistics window. For example.Open Window statement Open Table "States" As USA Map From USA The next example follows an Open Table statement with a TableInfo( ) function call. MapBasic will open “C:STATES. WIN_RULER). “STATES_2”). All rights reserved.

and Create Redistricter statement). Layout statement. etc. if necessary. it cannot be a point or text object. object2 is an object. Note: This dialog box is not strictly a window so does not have an entry in MAPBASIC. A dialog box that displays a list of currently opened tables. Browse. object2 ) object1 is an object. MapBasic retains all styles (color. and returns an object representing that intersection. Graph statement. Graph. The Help window (WIN_HELP). Syntax Overlap( object1. produces results similar to MapInfo Professional's Objects > Erase Outside command. Browse statement. The Message window used by the Print statement (WIN_MESSAGE). There is a separate statement for opening each type of document window (see the Map statement. 441 . Description The Overlap( ) function calculates the geographic intersection of two objects (the area covered by both objects). All rights reserved. it cannot be a point or text object.Overlap( ) function Window Name Legend Info Ruler Help Message TableList Window Description The Theme Legend window (WIN_LEGEND).DEF You cannot open a document window (Map. Reference Guide © 2006 MapInfo Corporation. MapBasic applies the current drawing styles. The Ruler tool window (WIN_RULER). then. Return Value An object that is the geographic intersection of object1 and object2. Set Window statement Overlap( ) function Purpose Returns an object representing the geographic intersection of two objects. Print statement. Layout) through the Open Window statement. See Also Close Window statement. The Info tool window (WIN_INFO).) of the original object1 parameter.

a region). the OverlayNodes( ) function does not add any nodes if input_object already has nodes at the points of intersection. See Also AreaOverlap( ) function. use the ObjectInfo( ) function to count the number of nodes (OBJ_INFO_NPNTS). or arc). Overlap( ) returns the portion of the linear object that is covered by the closed object. OverlayNodes( ) returns a polyline.) of the original input_object. See Also Objects Overlay statement 442 © 2006 MapInfo Corporation. The object returned retains all styles (color. rounded rectangle. OverlayNodes( ) returns a region object. overlay_object is an object that will be intersected with input_object. Return Value A region object or a polyline object. All rights reserved. etc. or ellipse). Even if two objects do intersect. with new nodes added at points where the object intersects a second object. Objects Intersect statement OverlayNodes( ) function Purpose Returns an object based on an existing object. Erase( ) function. MapBasic 8.5 . polyline. it may not be a point or text object. Description The OverlayNodes( ) function returns an object that contains all the nodes in input_object plus nodes at all locations where the input_object intersects with the overlay_object.OverlayNodes( ) function If one of the objects is linear (for example. a polyline) and the other object is closed (for example. it may not be a point or text object. If input_object is a linear object (line. To determine whether the OverlayNodes( ) function added any nodes to the input_object. Syntax OverlayNodes( input_object. If the input_object is a closed object (region. rectangle. overlay_object ) input_object is an object whose nodes will be included in the output object.

. possibly causing the loss of themes or cosmetic objects. MapInfo Professional physically deletes any rows that had been flagged as “deleted. include the optional Graphic keyword. Packing Access Tables The Pack Table statement saves a copy of the original Microsoft Access table without the column types that MapInfo Professional does not support. When you pack a table's data. Suppose you create custom labels and save them in a workspace. To save edits. packing a table's graphical objects may cause editing operations to be slower. MapInfo Professional prompts the user to save themes and/ or cosmetic objects (if themes or cosmetic objects are about to be lost). Also.” To pack a table's graphical objects. The Pack Table statement can include both the Graphic keyword and the Data keyword. Packing the graphical objects removes empty space from the map file. If you include the Interactive keyword. 443 . or LONG BINARY type columns. Description To pack a table's data. If a Microsoft Access table has MEMO. OLE. when you pack a table. (Within a workspace. and it must include at least one of the keywords. include the optional Data keyword. packing will not invalidate the custom labels. custom labels are stored with respect to row ID numbers. All rights reserved. you may get incorrect labels the next time you load the workspace. from the bottom of the Browser window). possibly invalidating custom labels stored in workspaces. use the Commit Table statement. those columns are lost during a pack. this statement cannot pack a table that has unsaved edits.Pack Table statement Pack Table statement Purpose Provides the functionality of MapInfo Professional's Table > Maintenance > Pack Table command. A Pack Table statement may cause map layers to be removed from a Map window. Example Pack Table parcels Data Reference Guide © 2006 MapInfo Corporation. resulting in a smaller table. However. This statement cannot pack linked tables.) If you only delete rows from the end of the table (i. you change the table's row ID numbers.e. Note: Packing a table can invalidate custom labels that are stored in workspaces. Syntax Pack Table table { Graphic | Data | Graphic Data } [ Interactive ] table is a string representing the name of an open table that does not have unsaved changes. If you delete rows from your table and pack the table.

TAB" s_filedir = PathToDirectory$(s_filespec) ' s_filedir now contains the string "C:\MAPINFO\DATA\" See Also PathToFileName$( ) function.PathToDirectory$( ) function See Also Open Table statement PathToDirectory$( ) function Purpose Returns only the specified file's directory.5 .TAB includes the directory “C:\MAPINFO\DATA\”. PathToTableName$( ) function PathToFileName$( ) function Purpose Returns just the file name from a specified file. Syntax PathToFileName$( filespec ) filespec is a string expression representing a full file specification. A full file specification can include a directory and a filename. Syntax PathToDirectory$( filespec ) filespec is a string expression representing a full file specification. s_filedir As String s_filespec = "C:\MAPINFO\DATA\STATES. All rights reserved. Return Value String Description The PathToDirectory$( ) function returns just the “directory” component from a full file specification. 444 © 2006 MapInfo Corporation. The file specification C:\MAPINFO\DATA\WORLD. MapBasic 8. Example Dim s_filespec.

MapInfo Professional removes the directory path from the beginning of the string and removes “. If the table Reference Guide © 2006 MapInfo Corporation.TAB" s_filename = PathToFileName$(s_filespec) ' filename now contains the string "STATES.PathToTableName$( ) function Return Value String Description The PathToFileName$( ) function returns just the “filename” component from a full file specification. . PathToTableName$( ) function PathToTableName$( ) function Purpose Returns a string representing a table alias (such as “_1995_Data”) from a complete file specification (such as “C:\MapInfo\Data\1995 Data. including the file extension if there is one. The file specification C:\MAPINFO\DATA\WORLD. spaces or punctuation marks) are replaced with the underscore character (_).TAB" See Also PathToDirectory$( ) function. on the title bar of a Browser window). s_filename As String s_filespec = "C:\MAPINFO\DATA\STATES.TAB file. The alias is the name by which a table appears in the MapInfo Professional user interface (for example. Syntax PathToTableName$( filespec ) filespec is a string expression representing a full file specification. To convert a file name to a table alias.TAB” from the end of the string. Any special characters (for example.TAB”). Example Dim s_filespec. Description Given a full file name that identifies a table's . this function returns a string that represents the table's alias. The PathToFileName$( ) function returns the file's name. 445 . up to 31 characters long. Return Value String.tab”).TAB includes a directory (“C:\MAPINFO\DATA\”) and a filename (“WORLD. A full file specification can include a directory and a filename. All rights reserved.

MakePen( width. such as the Create Line statement. the following Open Table statement uses the optional As clause to force the World table to use the alias “Earth”: Open Table "C:\MapInfo\Data\World. pattern. MapBasic 8. The keyword Pen may be followed by an expression which evaluates to a Pen value. Note that a table may sometimes be open under an alias that differs from its default alias. call the TableInfo( ) function with the TAB_INFO_NAME code. Syntax Pen pen_expr pen_expr is a Pen expression. if the user opens two tables that have identical names but different directory locations. All rights reserved. pattern. let you include a Pen clause to specify an object's line style. In either of these situations. so that both tables can be open at once. TableInfo( ) function Pen clause Purpose Specifies a line style for graphic objects.Pen clause name starts with a number. The Pen clause is not a complete MapBasic statement. If the resulting string is longer than 31 characters. for example. To determine the alias under which a table was actually opened. Example Dim s_filespec. For example. and color settings that dictate the appearance of a line or polyline object. PathToFileName$( ) function.5 . MapInfo Professional trims characters from the end.TAB" s_tablename = PathToTableName$(s_filespec) ' s_tablename now contains the string "STATES" See Also PathToDirectory$( ) function. MapInfo Professional assigns the second table a different alias. This expression can be a Pen variable: Pen pen_var 446 © 2006 MapInfo Corporation.tab" As Earth Furthermore. a set of thickness. Various object-related statements. color ) Description The Pen clause specifies a line style—in other words. the “default alias” returned by PathToTableName$( ) might not match the alias under which the table is currently open. MapInfo Professional inserts an underscore at the beginning of the alias. aliases cannot be longer than 31 characters. s_tablename As String s_filespec = "C:\MAPINFO\DATA\STATES.

usually from 1 to 7.Pen clause or a call to a function (for example. To create an invisible line style. BLUE) With some MapBasic statements (for example. see RGB( ) function on page 483. the name of a Pen variable). and color) within parentheses: Pen(1. 447 . 2. BLUE) Some MapBasic statements take a Pen expression as a parameter (for example. rather than a full Pen clause (the keyword Pen followed by the name of a Pen variable). Integer value from 1 to 118. the keyword Pen can be followed immediately by the three parameters that define a Pen style (width. Integer RGB color value. and use a pattern value of 1 (one). the CurrentPen( ) function or the MakePen( ) function) which returns a Pen value: Pen MakePen(1. pattern. Pattern 1 is invisible. All rights reserved. representing the thickness of the line (in pixels). specify a width of zero. the Set Map statement). pattern color Reference Guide © 2006 MapInfo Corporation. 2. The Alter Object statement is one example. see table below. The following table summarizes the components that define a Pen: Component width Description Integer value.

42. 42.9) Pen MakePen(1.6) (73.DEF" Dim cable As Object Create Line Into Variable cable (73.Pen clause The available pen patterns appear in the figure below. MapBasic 8. RGB( ) function.67. Set Style statement 448 © 2006 MapInfo Corporation. 2. MakePen( ) function.5. BLACK) See Also Alter Object statement.5 . CreateLine( ) function. Example Include "MAPBASIC. All rights reserved. CurrentPen( ) function. Create Pline statement.

PenWidthToPoints( ) function PenWidthToPoints( ) function Purpose Returns the point size for a given pen width. Example Include "MAPBASIC. MakePen( ) function. The pen width for a line style may be returned by the StyleAttr( ) function. use the IsPenWidthPixels( ) function. PenWidthToPoints( ) only returns values for pen widths that are in points. StyleAttr( ) function Reference Guide © 2006 MapInfo Corporation. To determine if pen widths are in pixels or points. Pen clause. IsPenWidthPixels( ) function. All rights reserved. 449 . Syntax PenWidthToPoints( penwidth ) penwidth is an integer greater than 10 representing the pen width. Any pen width of ten or greater is in points. The pen width returned by the StyleAttr( ) function may be in points or pixels.DEF" Dim CurPen As Pen Dim Width As Integer Dim PointSize As Float CurPen = CurrentPen( ) Width = StyleAttr(CurPen. Return Value Float Description The PenWidthToPoints( ) function takes a pen width and returns the point size for that pen. PEN_WIDTH) If Not IsPenWidthPixels(Width) Then PointSize = PenWidthToPoints(Width) End If See Also CurrentPen( ) function. PointsToPenWidth( ) function. Pen widths of less than ten are in pixels.

and stores the results in a temporary table called Results. Return Value Float Description The Perimeter( ) function calculates the perimeter of the obj_expr object. MapBasic 8. The Perimeter( ) function returns approximate results when used on rounded rectangles.Perimeter( ) function Perimeter( ) function Purpose Returns the perimeter of a graphical object. a Cartesian operation is performed. Generally. Syntax Perimeter( obj_expr. The Perimeter( ) function returns a length measurement in the units specified by the unit_name parameter. “km”). unit_name ) obj_expr is an object expression. See Set Distance Units statement on page 570 for the list of valid unit names. "km") ' The variable perim now contains ' the perimeter of the polygon that's attached to ' the first record in the World table. specify “mi” as the unit_name parameter. and polygons. You can also use the Perimeter( ) function within the Select statement. 450 © 2006 MapInfo Corporation. in which case. to obtain a length in miles. The following Select statement extracts information from the States table. MapBasic calculates the perimeter of a rounded rectangle as if the object were a conventional rectangle. the Results table will include a column showing each state's perimeter.5 . Because the Select statement includes the Perimeter( ) function. a spherical operation is performed unless the coordinate system is nonEarth. All rights reserved. The Perimeter( ) function is defined for the following object types: ellipses. unit_name is a string representing the name of a distance unit (for example. for example. Other types of objects have perimeter measurements of zero. MapInfo Professional performs a Cartesian or Spherical operation. Dim perim As Float Open Table "world" Fetch First From world perim = Perimeter(world. Example The following example shows how you can use the Perimeter( ) function to determine the perimeter of a particular geographic object. rounded rectangles. rectangles.obj. For the most part.

Return Value SmallInt Description The PointsToPenWidth( ) function takes a value in tenths of a point and converts that into a pen width. Set Distance Units statement PointsToPenWidth( ) function Purpose Returns a pen width for a given point size.DEF" Dim Width As Integer Dim p_bus_route As Pen Width = PointsToPenWidth(1. 451 . RED) See Also CurrentPen( ) function. Perimeter(obj. Example Include "MAPBASIC. 9. All rights reserved. MakePen( ) function. "mi") From states Into results See Also Area( ) function. Syntax PointsToPenWidth( pointsize ) pointsize is a float value in tenths of a point. IsPenWidthPixels( ) function. ObjectLen( ) function.PointsToPenWidth( ) function Open Table "states" Select state. Pen clause. StyleAttr( ) function Reference Guide © 2006 MapInfo Corporation. PenWidthToPoints( ) function.7) p_bus_route = MakePen(Width.

As a rule. Description MapInfo Professional automatically converts the input point from the current MapBasic coordinate system to a Long/Lat (WGS84) datum before performing the conversion to an MGRS string. so that no unnecessary intermediate conversions are performed. 43. Example 1: dim obj1 as Object dim s_mgrs As String dim obj2 as Object obj1 = CreatePoint(-74. 'Set the MapBasic coordsys to that of the table used 452 © 2006 MapInfo Corporation. using this as an intermediate coordinate system can cause a significant loss of precision in the final output.TAB" as MGRSfile ' ' ' ' When using the PointToMGRS$( ) or MGRSToPoint( ) functions.5 .PointToMGRS$( ) function PointToMGRS$( ) function Purpose Converts an object value representing a point into a string representing an MGRS (Military Grid Reference System) coordinate. Only point objects are supported. Syntax PointToMGRS$( inputobject ) inputobject is an object expression representing a point. the MapBasic coordinate system should be set to either Long/Lat (WGS84) or to the coordinate system of the source data table.669. Return Value String Examples The following examples illustrate the use of both the MGRSToPoint( ) and PointToMGRS$( ) functions.263) s_mgrs = PointToMGRS$(obj1) obj2 = MGRSToPoint(s_mgrs) Example 2: Open Table "C:\Temp\MyTable. However. All rights reserved. MapBasic 8. See Example 2 below. since datumless conversions are much less accurate. by default. it is very important to make sure that the current MapBasic coordsys matches the coordsys of the table where the point object is being stored. the MapBasic coordinate system is Long/Lat (no datum).

g. To set the font for the Message window. If a Print statement occurs while the Message window is closed. You could use the Message window to display status messages (“Record deleted”) or prompts for the user (“Select the territory to analyze. MapBasic opens the Message window automatically. Syntax Print message message is a string expression. Each Print statement is printed to a Reference Guide © 2006 MapInfo Corporation. pausing program execution until the user clicks OK. A MapBasic program can explicitly open the Message window through the Open Window statement. The Print statement is similar to the Note statement. All rights reserved. without pausing the program. Update MGRSfile Set Col3 = CentroidX(MGRSToPoint(Col2)) Update mgrstestfile ' MGRSfile Set Col4 = CentroidY(MGRSToPoint(Col2)) Commit Table MGRSfile Close Table MGRSfile See Also MGRSToPoint( ) function Print statement Purpose Prints a prompt or a status message in the Message window.Print statement Set CoordSys Table MGRSfile 'Update a Character column (e. The Message window is a special window which does not appear in MapInfo's standard user interface. The Print statement simply prints text to a window. the Note statement displays a dialog box. use the Set Window statement. However. 453 . The Message window lets you display custom messages that relate to a MapBasic program.”). Description The Print statement prints a message to the Message window. in that you can use either statement to display status messages or debugging messages. COL2) with MGRS strings from 'a table of points Update MGRSfile Set Col2 = PointToMGRS$(obj) 'Update two float columns (Col3 & Col4) with 'CentroidX & CentroidY information 'from a character column (Col2) that contains MGRS strings.

Include "MAPBASIC.DEF" ' needed for color name 'BLUE' Open Window Message ' open Message window Set Window Message Font ("Helv". to allow the user to scroll through the messages. and prints a message to the window. See Also Ask( ) function.25. print a string which includes the form-feed character (code 12): Print Chr$(12) 'This statement clears the Message window By embedding the line-feed character (code 10) in a message. Set Window statement Print # statement Purpose Writes data to a file opened in a Sequential mode (Output or Append). expr is an expression to write to the file. Syntax Print # file_num [ .0 ' make window 3" wide Height 1.. Close Window statement.5 . 10. Capitals" The Print statement converts each Tab character (code 09) to a space (code 32). Position (0. Example The next example displays the Message window. 1. To clear the Message window.0 ' make window 1" high Print "MapBasic Dispatcher now on line" Note: The buffer size for message window text has been doubled to 8191 characters. you can force a single message to be split onto two or more lines. Open Window statement. The following Print statement produces a two-line message: Print "Map Layers:" + Chr$(10) + " World. sets the window's size (three inches wide by one inch high).. After you have printed enough messages to fill the Message window. All rights reserved. 454 © 2006 MapInfo Corporation. expr ] file_num is the number of a file opened through the Open File statement.25) ' place in upper left Width 3. sets the window's font (Helvetica. scroll buttons appear at the right edge of the window. MapBasic 8. 0. bold. Note statement. BLUE) ' Helvetica bold.Print # statement new line in the Message window. 10-point).

The file_num parameter corresponds to the number specified in the As clause of the Open File statement. If you omit the Interactive keyword. MapInfo Professional prints the window automatically. otherwise. Syntax PrintWin [ Window window_id ][ Interactive ][ File output_filename ] [ Overwrite ] window_id is a window identifier. Write # statement PrintWin statement Purpose Prints an existing window. If the output file already exists. use the Write # statement instead of Print #. All rights reserved. Open File statement.PrintWin statement Description The Print # statement writes data to an open file. unless the Overwrite keyword is specified. If you include the Interactive keyword. 455 . To store a comma-separated list of expressions in each line of the file. without displaying the dialog box. MapInfo Professional displays the Print dialog box. If the statement includes the optional Window clause. an error will occur. Examples Example 1 Dim win_id As Integer Open Table "world" Map From world win_id = FrontWindow( ) ' Reference Guide © 2006 MapInfo Corporation. MapInfo Professional writes the expression expr to a line of the file. see the FrontWindow( ) function on page 304 and the WindowInfo( ) function on page 680 for more information about obtaining window identifiers. output_filename is a string representing the name of an output file. See Also Line Input statement. Description The PrintWin statement prints a window. The window_id parameter represents a window identifier. MapBasic prints the active window. MapBasic prints the specified window. The file must be open and in a sequential mode which allows output (Output or Append).

DEF. The window_id parameter specifies which Prism Map window to query. Return Value Float. attribute is an integer code. WindowInfo( ) function PrismMapInfo( ) function Purpose Returns properties of a Prism Map window.plt" See Also FrontWindow( ) function.5 . There are several numeric attributes that PrismMapInfo( ) can return about any given Prism Map window. Description The PrismMapInfo( ) function returns information about a Prism Map window. The attribute parameter should be one of the codes from the following table. attribute ) window_id is an integer window identifier. logical. or string. MapBasic 8.PrismMapInfo( ) function ' knowing the ID of the Map window. The attribute parameter tells the PrismMapInfo( ) function which Map window statistic to return. call the FrontWindow( ) function immediately after opening a window. indicating which type of information should be returned. Attribute PRISMMAP_INFO_SCALE Return Value Float result representing the PrismMaps scale factor. see RGB( ) function on page 483. depending on the attribute parameter. or call the WindowID( ) function at any time after the window's creation. Run Menu Command statement. codes are defined in MAPBASIC. Integer result representing the background color. ' the program could now print the map by ' issuing the statement: ' PrintWin Window win_id Interactive Example 2 PrintWin Window FrontWindow( ) File "c:\output\file. To obtain a window identifier. All rights reserved. Syntax PrismMapInfo( window_id. PRISMMAP_INFO_BACKGROUND 456 © 2006 MapInfo Corporation.

Float result representing the y-coordinate of the Cameras FocalPoint in the scene. 457 . Integer result representing the Light color. see RGB( ) function on page 483. Float result representing the z-coordinate of the Camera in the scene. Float result representing the x-coordinate of the Cameras FocalPoint in the scene. Float result representing the second value of the ViewUp Unit Normal Vector. Float result representing the y-coordinate of the Camera in the scene. Float result representing the cameras near clipping plane. Float result representing the y-coordinate of the Light in the scene. Float result representing the z-coordinate of the Camera's FocalPoint in the scene. Float result representing the x-coordinate of the Camera in the scene. Float result representing the first value of the ViewUp Unit Normal Vector. All rights reserved. Float result representing the third value of the ViewPlane Unit Normal Vector.PrismMapInfo( ) function Attribute PRISMMAP_INFO_LIGHT_X Return Value Float result representing the x-coordinate of the light in the scene. Float result representing the first value of the View Plane Unit Normal Vector. Float result representing the z-coordinate of the Light in the scene. Float result representing the third value of the ViewUp Unit Normal Vector. Float result representing the second value of the ViewPlane Unit Normal Vector. PRISMMAP_INFO_LIGHT_Y PRISMMAP_INFO_LIGHT_Z PRISMMAP_INFO_LIGHT_COLOR PRISMMAP_INFO_CAMERA_X PRISMMAP_INFO_CAMERA_Y PRISMMAP_INFO_CAMERA_Z PRISMMAP_INFO_CAMERA_FOCAL_X PRISMMAP_INFO_CAMERA_FOCAL_Y PRISMMAP_INFO_CAMERA_FOCAL_Z PRISMMAP_INFO_CAMERA_VU_1 PRISMMAP_INFO_CAMERA_VU_2 PRISMMAP_INFO_CAMERA_VU_3 PRISMMAP_INFO_CAMERA_VPN_1 PRISMMAP_INFO_CAMERA_VPN_2 PRISMMAP_INFO_CAMERA_VPN_3 PRISMMAP_INFO_CAMERA_CLIP_NEAR Reference Guide © 2006 MapInfo Corporation.

5 . PRISMMAP_INFO_CAMERA_FOCAL_Y) Print "PRISMMAP_INFO_CAMERA_FOCAL_Z: " + PrismMapInfo(FrontWindow( ).PrismMapInfo( ) function Attribute PRISMMAP_INFO_CAMERA_CLIP_FAR Return Value Float result representing the cameras far clipping plane. PRISMMAP_INFO_CAMERA_VU_1) Print "PRISMMAP_INFO_CAMERA_VU_2: " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_CAMERA_VU_3) Print "PRISMMAP_INFO_CAMERA_VPN_1: " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_LIGHT_COLOR) Print "PRISMMAP_INFO_CAMERA_X: " + PrismMapInfo(FrontWindow( ). PRISMMAP_ INFO_CAMERA_X) Print "PRISMMAP_INFO_CAMERA_Y : " + PrismMapInfo(FrontWindow( ). Not previously documented. PRISMMAP_ INFO_CAMERA_Z ) Print "PRISMMAP_INFO_CAMERA_FOCAL_X: " + PrismMapInfo(FrontWindow( ). PRISMMAP_ INFO_SCALE) Print "PRISMMAP_INFO_BACKGROUND: " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_CAMERA_VPN_3) Print "PRISMMAP_INFO_CAMERA_CLIP_NEAR: " + PrismMapInfo(FrontWindow( ). PRISMMAP_ INFO_LIGHT_Y ) Print "PRISMMAP_INFO_LIGHT_Z: " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_CAMERA_VPN_2) Print "PRISMMAP_INFO_CAMERA_VPN_3: " + PrismMapInfo(FrontWindow( ). PRISMMAP_ INFO_UNITS) Print "PRISMMAP_INFO_LIGHT_X : " + PrismMapInfo(FrontWindow( ). String for Infotip. PRISMMAP_INFO_INFOTIP_EXPR Example This example prints out all the state variables specific to the PrismMap window: include "Mapbasic. PRISMMAP_ INFO_CAMERA_Y ) Print "PRISMMAP_INFO_CAMERA_Z : " + PrismMapInfo(FrontWindow( ).def" Print "PRISMMAP_INFO_SCALE: " + PrismMapInfo(FrontWindow( ). MapBasic 8. PRISMMAP_INFO_CAMERA_VPN_1) Print "PRISMMAP_INFO_CAMERA_VPN_2: " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_CAMERA_VU_2) Print "PRISMMAP_INFO_CAMERA_VU_3: " + PrismMapInfo(FrontWindow( ). PRISMMAP_ INFO_LIGHT_X ) Print "PRISMMAP_INFO_LIGHT_Y : " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_CAMERA_FOCAL_Z) Print "PRISMMAP_INFO_CAMERA_VU_1: " + PrismMapInfo(FrontWindow( ). 458 © 2006 MapInfo Corporation. All rights reserved. PRISMMAP_INFO_BACKGROUND) Print "PRISMMAP_INFO_UNITS: " + PrismMapInfo(FrontWindow( ). PRISMMAP_ INFO_LIGHT_Z) Print "PRISMMAP_INFO_LIGHT_COLOR: " + PrismMapInfo(FrontWindow( ). PRISMMAP_INFO_CAMERA_FOCAL_X) Print "PRISMMAP_INFO_CAMERA_FOCAL_Y: " + PrismMapInfo(FrontWindow( ).

Example Dim s_prog_dir As String s_prog_dir = ProgramDirectory$( ) See Also HomeDirectory$( ) function. PRISMMAP_INFO_CAMERA_CLIP_FAR) See Also Create PrismMap statement. Reference Guide © 2006 MapInfo Corporation.ProgramDirectory$( ) function PRISMMAP_INFO_CAMERA_CLIP_NEAR) Print "PRISMMAP_INFO_CAMERA_CLIP_FAR: " + PrismMapInfo(FrontWindow( ). n is a number at which the job is finished. Syntax ProgramDirectory$( ) Return Value String Description The ProgramDirectory$( ) function returns a string representing the directory path where the MapInfo Professional software is installed. 459 . handler is the name of a Sub procedure. Set PrismMap statement ProgramDirectory$( ) function Purpose Returns the directory path to where the MapInfo Professional software is installed. All rights reserved. SystemInfo( ) function ProgressBar statement Purpose Displays a dialog box with a Cancel button and a horizontal progress bar. Syntax ProgressBar status_message Calling handler [ Range n ] status_message is a string value displayed as a message in the dialog box.

If the handler assigns a value of negative one to the ProgressBar variable (ProgressBar = -1) then MapBasic detects that the operation is finished. The sub procedure should perform a small amount of processing. MapBasic 8. If the user did click Cancel. The handler indicates the job status by assigning a value to the special MapBasic variable. and accordingly halts the ProgressBar loop and removes the dialog box. n. then the current percent of completion is 25%. The n parameter is a number. If no Range n clause is specified. MapBasic calls the specified handler sub procedure. if the ProgressBar statement specified the Range clause Range 400 and if the current value of the ProgressBar variable is 100. to reflect the latest figure of percent completion. If the user never clicks Cancel. At that time. such as “Processing data…”. MapBasic automatically calls the handler sub procedure again. the sub procedure must perform certain actions in order for it to interact with the ProgressBar statement. The handler parameter is the name of a sub procedure in the same MapBasic program. As described below. the ProgressBar statement repeatedly calls the procedure until the operation is finished. Once a ProgressBar statement has been issued.000 rows of a table. specifically a few seconds' worth of processing at most. The bar indicates the percentage of completion of a lengthy operation. representing the count value at which the operation will be finished. and proceeds with the statements which follow the ProgressBar statement (and thus. Following the ProgressBar statement. if an operation needs to process 7. and MapBasic will display the horizontal bar as being 25% filled. For example.ProgressBar statement Restrictions You cannot issue the ProgressBar statement through the MapBasic window. For example. Alternately. Description The ProgressBar statement displays a dialog box with a horizontal progress bar and a Cancel button. The handler procedure must be written in such a way that each call to the procedure performs only a small percent of the total job. also named ProgressBar. which is displayed in the dialog box. All rights reserved. the lengthy operation is never completed). if the handler procedure assigns a value other than negative one to the ProgressBar variable (ProgressBar = 50) then MapBasic re-displays the dialog box's “percent complete” horizontal bar. a MapBasic program can call CommandInfo(CMD_INFO_DLG_OK) to determine whether the operation finished or whether the user cancelled first (see below). the ProgressBar statement might specify 7000 as the n parameter. if the user did not click Cancel. MapBasic checks to see if the user clicked the Cancel button. MapBasic calculates the current percent of completion by dividing the current value of the ProgressBar variable by the Range setting. The user can halt the operation by clicking the Cancel button. and then it should end. the n parameter has a default value of 100. The status_message parameter is a string value. MapBasic will repeatedly call the handler procedure until the user clicks Cancel or until the handler procedure indicates that the procedure is finished.5 . 460 © 2006 MapInfo Corporation. MapBasic removes the dialog box. Alternately. When a program issues a ProgressBar statement.

" Else Note "Operation interrupted!" End If End Sub Sub write_out Dim start_time As Float start_time = Timer( ) ' process records until either (a) the job is done." Calling write_out Range 600 If CommandInfo(CMD_INFO_STATUS) Then Note "Operation complete! Thanks for waiting.def" Declare Sub Main Declare Sub write_out Global next_row As Integer Sub Main next_row = 1 ProgressBar "Writing data. If the user does not press Cancel. All rights reserved. In this example. Example The following example demonstrates how a procedure can be written to work in conjunction with the ProgressBar statement. perhaps we have a table with 600 rows. ''' '''''''''''''''''''''''''''''''''''''''''' next_row = next_row + 1 Loop ' Now figure out why the Do loop terminated: was it ' because the job is done. which then automatically calls the sub procedure. The write_out procedure processes records until two seconds have elapsed. and each row must be processed in some fashion. ' or (b) more than 2 seconds elapse within this call Do While next_row <= 600 And Timer( ) . or FALSE if the operation halted because the user clicked cancel.start_time < 2 '''''''''''''''''''''''''''''''''''''''''' ''' Here. or because more than 2 ' seconds have elapsed within this iteration? If next_row > 600 Then ProgressBar = -1 'tell caller "All Done!" Else Reference Guide © 2006 MapInfo Corporation. MapBasic will repeatedly call the write_out procedure until the entire task is done. Include "mapbasic. the function call CommandInfo(CMD_INFO_DLG_OK) returns TRUE if the operation was complete. write_out. 461 .. The main procedure issues the ProgressBar statement.. or because the user clicked the Cancel button. and then returns (so that MapBasic can check to see if the user pressed Cancel). we would do the actual work ''' ''' of processing the file. we have an operation involving 600 iterations.ProgressBar statement The statements following the ProgressBar statement often must determine whether the ProgressBar loop halted because the operation was finished. Immediately following the ProgressBar statement.

thus producing a result string with “proper” capitalization. and then capitalizes only the first letter of each word in the string. This style of capitalization is appropriate for proper names. Example Dim name.Proper$( ) function ProgressBar = next_row 'tell caller "Partly done" End If End Sub See Also CommandInfo( ) function. Return Value String Description The Proper$( ) function first converts the entire string_expr string to lower case. UCase$( ) function 462 © 2006 MapInfo Corporation. Print statement Proper$( ) function Purpose Returns a mixed-case string.5 . Syntax Proper$( string_expr ) string_expr is a string expression. propername As String name = "ed bergen" propername = Proper$(name) ' propername now contains the string "Ed Bergen" name = "ABC 123" propername = Proper$(name) ' propername now contains the string "Abc 123" name = "a b c d" propername = Proper$(name) ' propername now contains the string "A B C D" See Also LCase$( ) function. Note statement. where only the first letter of each word is capitalized. All rights reserved. MapBasic 8.

] var_name filenum is the number of a file opened through an Open File statement. Syntax Put [ # ] filenum. Return Value A float value equal to AreaOverlap( object1. use the Print # statement or the Write # statement instead of Put. Syntax ProportionOverlap( object1. var_name is the name of a variable which contains the data to be written. as summarized below: Reference Guide © 2006 MapInfo Corporation. the file position points to the first record of the file (record 1). Note: If the Open File statement specified a sequential access mode (Output or Append). position is the file position to write to (does not apply to sequential file access). Description The Put statement writes to an open file. If the Open File statement specified Random file access. The number of bytes written depends on the variable type. see the ByteOrder clause of the Open File statement on page 435. one variable can be written at a time.ProportionOverlap( ) function ProportionOverlap( ) function Purpose Returns a number that indicates what percentage of one object is covered by another object. See Also AreaOverlap( ) function Put statement Purpose Writes the contents of a MapBasic variable to an open file. The byte sequence written to the file depends on whether the hardware platform's byte ordering. the Put statement's Position clause can be used to indicate which record in the file to overwrite. object2 is the top object (not text or points). object2 ) object1 is the bottom object (not text or points). All rights reserved. If the Open File statement specified Binary file access. When the file is opened. [ position. 463 . object2 ) / Area( object1 ).

Print # statement. In other words. the position is incremented by the number of bytes written. Open File statement. 464 © 2006 MapInfo Corporation. The Position parameter sets the file pointer to a specific offset in the file.Randomize statement Variable Type Logical SmallInt Integer Float String Date Other Variable types Storage In File One byte. unless the program includes a Randomize statement. the Put statement cannot specify a fixed-length string variable which is longer than the record length of the file. the Put statement cannot specify a variablelength string variable. Without this statement before the first call to the Rnd( ) function. MapBasic 8. Write # statement Randomize statement Purpose Initializes MapBasic's random number function. any string variable used in a Put statement must be fixed-length. Syntax Randomize [ With seed ] seed is an integer expression. Description The Randomize statement “seeds” the random number generator so that later calls to the Rnd( ) function produce random results. the position is initialized to 1 (the start of the file). If the file was opened in Random mode. If the file was opened in Binary mode. All rights reserved. byte month. byte day Cannot be written. As a Put is done. When the file is opened. Two byte integer Four byte integer Eight byte IEEE format Length of string plus a byte for a 0 string terminator Four bytes: Small integer year. the Put simply writes to the current file position. the actual series of random numbers will follow a standard list.5 . If the Position clause is not used. See Also EOF( ) function. Get statement. the sequence of values returned by the Rnd( ) function will follow the same pattern each time the application is run. The Randomize statement is only needed once in a program and should occur prior to the first call to the Rnd( ) function. either 0 or non-zero.

If you omit the With clause. Symbol. the ReadControlValue( ) function returns the value of the last control which was operated by the user. All rights reserved. logical. Example Randomize See Also Rnd( ) function ReadControlValue( ) function Purpose Reads the current status of a control in the active dialog box. Brush. Pen. Note: A dialog box control does not have a unique ID unless you include an ID clause in the Dialog statement’s Control clause. thus. The integer id_num parameter specifies which control MapBasic should read. string. A ReadControlValue( ) function call is only valid while there is an active dialog box. 465 . To explicitly specify which control you want to read. Reference Guide © 2006 MapInfo Corporation. static text labels).ReadControlValue( ) function If you include the With clause. Use the With clause if you need to create repeatable test scenarios. The table below summarizes what types of values will be returned by various controls. Some types of dialog box controls have no readable values (for example. MapBasic automatically seeds the pseudo-random number generator using the current system clock. Note that special processing is required for handling MultiListBox controls: since the user can select more than one item from a MultiListBox control. Syntax ReadControlValue( id_num ) id_num is an integer value indicating which control to read. pass ReadControlValue( ) an integer ID that identifies the appropriate control. or Font. depending on the type of control Description The ReadControlValue( ) function returns the current value of one of the controls in an active dialog box. where your program generates repeatable sequences of “random” numbers. the seed parameter is used as the seed value for the pseudo-random number generator. a program may need to call ReadControlValue( ) multiple times to obtain a complete list of the selected items. you may only call the ReadControlValue( ) function from within a dialog box control's handler procedure. If the id_num parameter has a value of -1 (negative one). Return Value Integer.

The first call to ReadControlValue( ) returns the number of the first selected list item (1 if the first list item is selected). the application calls ReadControlValue( ) to read in the name that was typed. Font value. CheckBox DocumentWindow RadioGroup PopupMenu ListBox BrushPicker FontPicker PenPicker SymbolPicker MultiListBox Error Conditions The ERR_FCN_ARG_RANGE error is generated if an argument is outside of the valid range. All rights reserved. representing the current contents of the text box. FALSE otherwise.ReadControlValue( ) function Control Type EditText ReadControlValue( ) Return Value String. Integer identifying one of the selected items. up to 32. SmallInt value identifying which item is selected (1 for the first item). Pen value.5 . Integer that represents the HWND for the window control. The user can select one or more of the items in a MultiListBox control. Symbol value. Brush value. the string may include Chr$(10) values. When ReadControlValue( ) returns zero. SmallInt value identifying the selected list item (1 for the first. your program may need to call ReadControlValue( ) multiple times in order to determine how many items are selected. If the user clicks OK. This HWND should be passed as the parent window handle in the Set Next Document statement. 0 if none). indicating that the user entered linefeeds (for example. MapBasic 8. TRUE if the check box is currently selected. Example The following example creates a dialog box that asks the user to type a name in a text edit box. The ERR_INVALID_READ_CONTROL error is generated if the ReadControlValue( ) function is called when no dialog box is active. the list of selected items has been exhausted. in Windows. by pressing Ctrl-Enter). 466 © 2006 MapInfo Corporation. SmallInt value identifying which button is selected (1 for the first button). the second call will return the number of the second selected list item. Subsequent calls to ReadControlValue( ) then begin back at the top of the list of selected items. If ReadControlValue( ) returns zero on the first call. none of the list items are selected. etc. Since ReadControlValue( ) can only return one piece of information at a time. if the EditText is tall enough to accommodate multiple lines of text.767 bytes long.

Dialog statement. Dialog Remove statement ReDim statement Purpose Re-sizes an array variable. Reference Guide © 2006 MapInfo Corporation. .. 100 Width 50 Title "Cancel" Control StaticText Position 5. 467 . Description The ReDim statement re-sizes (or “re-dimensions”) one or more existing array variables. 120 Width 50 Title "OK" Calling okhandler Control CancelButton Position 135. The maximum value is 32. 10 Width 160 Value "(your name here)" Id 23 'arbitrary ID number End Sub Sub okhandler ' this sub is called when/if the user ' clicks the OK control Note "Welcome aboard. The variable identified by var_name must have already been defined as an array variable through a Dim statement or a Global statement. " + ReadControlValue(23) + "!" End Sub See Also Alter Control statement. All rights reserved.767. 10 Title "Please enter your name:" Control EditText Position 55.ReDim statement Declare Sub Main Declare Sub okhandler Sub Main Dialog Title "Sign in. Syntax ReDim var_name ( newsize ) [ . ] var_name is a string representing the name of an existing local or global array variable. Dialog Preserve statement. Please" Control OKButton Position 135.. newsize is an integer value dictating the new array size.

If your program no longer needs a given array variable.serial_nums(10) See Also Dim statement. redimension the "new_customers" array. Presumably. MapBasic does not allow custom subscript settings for arrays. redimension the "serial_nums" array element ' of the first item in the "new_customers" array: ReDim new_customers(1). Unlike some BASIC languages.5 . cur_size As Integer ' The following statements determine the current ' size of the array. a MapBasic array's first element always has a subscript of one. Global statement. and then enlarge the array through the ReDim statement. If you store values in an array.ReDim statement The ReDim statement can increase or decrease the size of an existing array. and also on arrays that are Type elements. and then ReDim the array to ' a size 10 elements larger cur_size = UBound(names_list) ReDim names_list(cur_size + 10) ' ' ' ' The following statement ReDims the array to a size of zero elements. Example Dim names_list(10) As String. ' making it five items deep: ReDim new_customers(5) ' Now. the ReDim statement can operate on arrays of custom Type variables. UBound( ) function 468 © 2006 MapInfo Corporation. the ReDim statement can re-size that array to have zero elements (this minimizes the amount of memory required to store variables). this array is no longer needed. MapBasic 8. All rights reserved. Type customer name As String serial_nums(0) As Integer End Type Dim new_customers(1) As customer ' First. the values you stored in the array remain intact. ReDim names_list(0) As shown below. and it is resized to zero for the sake of saving memory.

. MapY2 ) ( RasterX2.. MapY1 ) ( RasterX1.... range_name is a string indicating a named range (for example. delim_char specifies the character used as a column delimiter. this argument must identify a valid Access database. If the file uses commas.. database. 469 . RasterY2 )... If the file uses Tab as the delimiter. [ Symbol.. MapY3 ) ( RasterX3. text file..] [ Linestyle Pen(. specify 9...) ] [ Regionstyle Pen(... [ PersistentCache { ON | OFF } ] [ Symbol.) Brush(... .) Brush(. If you are registering an Access table. or grid image.. an Excel range can be specified as “Sheet1!R1C1:R9C6” or as “Sheet1!A1:F9”). text file. see CharSet clause on page 125. “MyTable”) or a cell range (for example. raster. raster. RasterY3 ) [. ] [ Linestyle Pen(.) ] Type "XLS" [ Titles ] [ Range range_name ] [ Interactive ] | Type "Access" Table table_name [ Password pwd ] [ CharSet char_set ]} Type ODBC Connection { Handle ConnectionNumber | ConnectionString } Toolkit toolkitname Cache { ON | OFF } [ Autokey { ON | OFF }] Table SQLQuery [ Versioned { ON | OFF }] [ Workspace WorkspaceName ] [ ParentWorkspace ParentWorkspaceName ] Type "GRID" | Type "RASTER" [ ControlPoints ( MapX1. RasterY1 ). ( MapX2.. All rights reserved.... Syntax Register Table source_file { Type "NATIVE" | Type "DBF" [ Charset char_set ] | Type "ASCII" [ Delimiter delim_char ][ Titles ][ CharSet char_set ] | Type "WKS" [ Titles ] [ Range range_name ] | Type "WMS" Coordsys... ] Type "SHAPEFILE" [ Charset char_set ] CoordSys. specify 44.) ] [ Regionstyle Pen(. char_set is the name of a character set.. ( MapX3. spreadsheet. Type "WFS" [ Charset char_set ] Coordsys.. ] ] [ CoordSys . or grid image..) ] [ Into destination_file ] source_file is a string that represents the name of an existing database.Register Table statement Register Table statement Purpose Builds a MapInfo Professional table from a spreadsheet. Reference Guide © 2006 MapInfo Corporation.

ConnectionNumber is an integer value that identifies an existing connection to an ODBC database. Note: If the Interactive keyword is specified for type XLS. ControlPoints are optional. If Autokey is set ON. The Symbol clause specifies the symbol style to be used for a point object type created from a shapefile. If PersistentCache is set to Off. Grid.ID files generated during the opening of Shapefiles are saved on hard disk after closing a table. PersistentCache On specifies if . destination_file specifies the name to give to the MapInfo table (. but can be specified if the type is Grid or Raster. it must be followed by at least 3 pairs of Map and Raster coordinates which are used to georegister an image. a . the file is built in the same directory as the source file. See Server_Connect( ) function on page 522.TAB file is generated without user input and is created as though the user had selected “Display” when opening a raster image from the File > Open dialog box.ID files are deleted after closing a table and are be generated each time the table is opened. Regionstyle Pen Brush clause specifies the line style and fill style to be used for a region object type created from a shapefile. but it can be specified for the Grid or Raster Types. but can be specified if the type XLS. or Raster. This is useful when registering a raster image that has an associated World file. they will override and replace any control points associated with the image or an associated World file. MapBasic 8.5 . If the ControlPoints keyword is specified. Interactive is not a valid parameter for registering SHP files. toolkitname is “ODBC” or “ORAINET. the CoordSys clause is mandatory. WorkspaceName is the name of the current workspace in which the table will be operated. The name is case sensitive. then these . ConnectionString is a string used to connect to a database server. If the ControlPoints are specified.” SQLQuery is the SQL query used to define the MapInfo table. pwd is the database-level password for the database. This string may include a path. If the Interactive keyword is specified for type Grid or Raster.MAP and . if it does not include a path.TAB file). to be specified when database security is turned on. The compiler will indicate an error if it is missing. For other Types. the table is registered without key auto-increment. If Autokey is set OFF or this option is ignored. If the Interactive keyword is not specified. 470 © 2006 MapInfo Corporation. it overrides and replaces any coordinate system associated with the image. the user is prompted for any missing control point or projection information. For WMS and Shapefiles. The Interactive keyword is optional. the table is registered with key auto-increment option.Register Table statement table_name is a string that identifies an Access table. it instructs the interface to display the Set Field Properties window when importing Excel files. the CoordSys clause is optional. Versioned indicates if the table to be opened is an version-enabled (ON) table or not (OFF). The Linestyle Pen clause specifies the line style to be used for a line object type created from a shapefile. If CoordSys is specified.MAP and . All rights reserved.

ASCII. Description Before you can use a non-native file (for example. you must register the file. The table is not opened automatically. filename.TAB file that is generated is the same as if the user selected “Display” when opening a raster image from the File > Open dialog box.TAB file is created. use an Open Table statement. See CharSet clause on page 125 for more information. If you omit the CharSet clause. subsequent MapInfo Professional sessions simply Open the table.TAB file that is generated depends upon if georegistration information can be found in the image file or associated World file. MapInfo Professional registers that column in the . followed by one of the following character constants: NATIVE. The Titles clause indicates that the row before the range of data in the worksheet should be used as column titles. Once the Register Table operation has built a table file. By default. the . The Into clause is used to override the table name or location of the .TAB file on a volume that is not read-only. DBF. The Register Table statement does not copy or alter the original data file.TAB file. To open the table. This consists of the keyword Type.TAB file is created. Access. the coordsys string is read from the grid file and a MapInfo . The default delimiter is a TAB. MapInfo Professional modifies the Access table by adding a column called MAPINFO_ID with the counter datatype. The Register Table statement tells MapInfo Professional to examine a non-native file (for example.TAB file. WKS. Raster. Registering Access Tables When you register an Access table. XLS. If a raster file is being registered. you can access the file as an MapInfo table. MapInfo Professional uses the default character set for the hardware platform that is in use at run-time. Note: Do not alter the counter column in any way. The other information is necessary for preparing certain types of tables. rather than repeat the Register Table operation. it scans the data. you need to store the . and creates a separate table file. the coordsys string is read from the grid file and a MapInfo . MapInfo Professional checks for a counter column with a unique index. and stored in the same directory. If there is already a counter column. or Grid. If the type of file being registered is a grid. Instead. the . The char_set parameter should be a string such as “WindowsLatin1”. 471 . The column is read-only. The Delimiter clause is followed by a string containing the delimiter character. Reference Guide © 2006 MapInfo Corporation. The CharSet clause specifies a character set. If the Access table does not have a counter column. All rights reserved. Once the Register Table operation has built the appropriate table file.Register Table statement ParentWorkspaceName is the name of parent workspace of the current workspace. when reading a read-only device such as a CD-ROM. It must be exclusively maintained automatically by MapInfo Professional.DBF) and build a corresponding table file (filename. In this case. However. Note: Each data file need only be registered once. If a raster file is being registered. The Type clause specifies where the file came from originally. a dBASE file) in MapInfo. the counter column does not display in MapInfo. The Range clause allows the specification of a named range to use.TAB). If the type of file being registered is a grid. it will be named the same as the data file. determines the datatypes of the columns.

if you want to download rows pertaining to Ontario. There will be a problem if a client-side join (through the SQL Select menu item or MapBasic) is done against two or more SPATIALWARE tables that are stored in different coordinate systems. If you don't open a map table. MapBasic 8.PWD=mipro " toolkit "ORAINET" Autokey ON Into "C:\projects\data\testscripts\english\remote\SmallIntEGER. For Live Access.TAB" Open Table "C:\Projects\Data\TestScripts\English\remote\SmallIntEGER. FastEdit is not supported. Special Access datatypes. the ReadOnly checkbox on the save table dialog box is grayed out. With MS ACCESS if the key is character. • • • • • • Example The following example creates a tab file and then opens the tab file. the entire database table will be downloaded all at once. All rights reserved. will be used or not.TAB" Interactive 472 © 2006 MapInfo Corporation. zoom in to Ontario on the map. only rows within the map window's MBR (minimum bounding rectangle). if the key is char(5) the value 'aaaa' will look like a deleted row. which could take a long time. Autokey is the indicator to tell if the new feature. As a result. will be downloaded. such as OLE objects and binary fields. Changes made by another user are not visible until a browser is scrolled or somehow refreshed.5 .Register Table statement Access datatypes are translated into the closest MapInfo datatypes. canada. it does not display rows where the key value is less than the full column width for example. If the Cache OFF statement is before the connection string an error will be generated at compile time. An MBR search returns the row or 2). key auto-increment.UID=mipro. This is not an efficient thing to do (it is better to do the join in the SQL statement that defines the table) but it is a problem in the current build. For example.tab) for the database table.""SMALLINTEGER""" CONNECTION "SRVR=scout. The following is a list of known problems/issues with live access: • • • Every table must have a single unique key column. Inserts by another user are not seen until either: 1). Register Table "SMALLINTEGER" TYPE ODBC TABLE "Select * From ""MIPRO"". Open a map table and zoom in to an area that corresponds to a subset of rows you wish to see from the database table. Registering ODBC Tables Before accessing a table live from a remote database. PACK command is issued In addition if cache is on another users updates may not appear until the cache is invalidated by a pan or zooming out. Oracle 7 tables that are indexed on a decimal field larger than 8 bytes will cause MapInfo Professional to crash when editing. in this case Ontario. it is highly recommended that you first open a map table (for example. are not editable in MapInfo Professional. when you open the database table. If the server is Oracle.

TAB" Interactive Map From odbc_cancaps Example 3 Registering a completely georeferenced raster image (the raster handler can return at least three control points and a projection).dbf" Type "DBF" Into "Report23" Open Table "c:\mapinfo\data\Report23" Example 2 Open Table "C:\Data\CANADA\Canada. It is also possible to set styles that will be used when shapefile objects are displayed in MapInfo Professional.PWD=informix. Register Table "RasterWithWorld.tif" type "raster" into "GeoRef. Since a shapefile itself does not contain projection information.5. 0 into "RasterWithWorld. 62.HOST=adak. Projection and style information is stored as metadata in the TAB file.can_caps" CONNECTION DSN=ius_adak.TAB" Example 4 Registering a raster image that has an associated World file containing control point information.SERVICE=sqlexec.Register Table statement Map From SMALLINTEGER Registering Shapefiles When you register shapefiles. -96. 29. Register Table "GeoRef.TAB" Reference Guide © 2006 MapInfo Corporation. Note: Interactive is not a valid parameter to use when registering SHP files. "m". they can be opened in MapInfo Professional with read-only access.PROTOCOL=onsoctcp. SERVER=adak_tli.DATABASE=sw.tif" type "raster" coordsys earth projection 9. 473 . 23. 45. 0. Examples Example 1 Register Table "c:\mapinfo\data\rpt23. but no projection.tab" Interactive Map From Canada set map redraw off Set Map Zoom 1000 Units "mi" set map redraw on Register Table "odbc_cancaps" TYPE ODBC TABLE "Select * From informix. All rights reserved." Into "D:\MI\odbc_cancaps. you must specify a CoordSys clause.UID=informix.5.TAB" Open Table "D:\MI\odbc_cancaps.

(2000.TAB" Open Table "C:\Temp\CNTYLN. Register Table "Gwmusa" TYPE ODBC TABLE "Select * From ""MIUSER"".16711935) Into "C:\Temp\CNTYLN. MapBasic 8. 45. 29. 0. Register Table "NoRegistration.2).tab" Open Table "C:\Projects\Data\TestScripts\English\remote\Gwmusa. 62. 0 into "NoRegistration.5.tab" Example 6 The following example registers a shapefile. Server Create Workspace statement.26.3000) (2.2000) (1. -96. 33 PersistentCache Off linestyle Pen (2.UID=miuser. Server Link Table statement Relief Shade statement Purpose Adds relief shade information to an open grid table.6) coordsys earth projection 9.TAB" Interactive Map From Gwmusa See Also Open Table statement.SHP" TYPE SHAPEFILE Charset "WindowsLatin1" CoordSys Earth Projection 1. 3).Relief Shade statement Example 5 Registering a raster image that has no control point or projection information.""GWMUSA""" CONNECTION "SRVR=troyny. "m".6000) (5. Syntax Relief Shade Grid tablename Horizontal xy_plane_angle Vertical incident_angle Scale z_scale_factor 474 © 2006 MapInfo Corporation. All rights reserved. 23.5. (5000.BMP" type "raster" controlpoints (1000.TAB" Interactive Map From CNTYLN Example 7 The following example creates a tab file and then opens the tab file.5 .PWD=miuser" toolkit "ORAINET" Versioned On Workspace "MIUSER" ParentWorkspace "LIVE" Into "C:\projects\data\testscripts\english\remote\Gwmusa. Register Table "C:\Shapefiles\CNTYLN. Create Table statement.

so to place the light source in the NorthWest. Note: MapInfo 3. of the light source in the horizontal or xy plane. Description This statement is used by the SYMBOL. Syntax 1 (MapInfo 3. this can change the set of symbols displayed in the Options > Symbol Style dialog box. Increasing the z_ scale_factor enhances the shading effect by exaggerating the vertical component. 475 . xy_plane_angle is the direction angle. A positive angle places the light source counterclockwise. set xy_plane_angle to 135.Reload Symbols statement tablename is the alias name of the grid to which relief shade information is being calculated. Example Relief Shade Grid Lumens Horizontal 135 Vertical 45 Scale 30 Reload Symbols statement Purpose Opens and reloads the MapInfo symbol file. An incident_angle of 90 places the light source directly overhead. z_scale_factor is the scale factor applied to the z-component of each grid cell. which allows users to create custom symbols. incident_angle is the angle of the light source above the horizon or xy plane. An xy_plane_angle of zero represents a light source shining from due East. in degrees.0 and has been maintained in subsequent versions of MapInfo Professional. An incident_angle of zero represents a light source right at the horizon. All rights reserved.MBX utility.0 Symbols refers to the symbol set that came with MapInfo Professional for Windows 3. This can be used to bring out more detail in relatively flat grids.0 Symbols) Reload Symbols Syntax 2 (Bitmap File Symbols) Reload Custom Symbols From directory directory is a string representing a directory path. See Also Alter Object statement Reference Guide © 2006 MapInfo Corporation.

The MapGenHandler Automation method takes one argument: a string. RemoteMsgHandler procedure Purpose A reserved procedure name. Description RemoteMapGenHandler is a special-purpose MapBasic procedure name.MB. MapBasic 8. see the sample program MAPSRVR.RemoteMapGenHandler procedure RemoteMapGenHandler procedure Purpose A reserved procedure name. MapInfo Professional calls the RemoteMapGenHandler procedures of any MapBasic applications that are running. All rights reserved. The MapGenHandler method is part of the MapGen Automation model introduced in MapInfo Professional 4. and you call the MapGenHandler method. called when an OLE Automation client calls the MapGenHandler Automation method. If you are using OLE Automation to control MapInfo Professional. which is invoked through OLE Automation. Syntax Declare Sub RemoteMsgHandler Sub RemoteMsgHandler statement_list End Sub statement_list is a list of statements to execute upon receiving an execute message. Syntax Declare Sub RemoteMapGenHandler Sub RemoteMapGenHandler statement_list End Sub statement_list is a list of MapBasic statements to execute when the OLE Automation client calls the MapGenHandler method. Example For an example of using RemoteMapGenHandler.1. you can retrieve the string argument by issuing the function call CommandInfo(CMD_INFO_MSG) and assigning the results to a string variable. 476 © 2006 MapInfo Corporation. Within the RemoteMapGenHandler procedure. called when a remote application sends an execute message.5 .

that application can initiate a conversation with MapInfo Professional. Within the RemoteMsgHandler procedure. The DDE conversation must use the name of the sleeping application (for example. MapInfo Professional automatically calls the RemoteMsgHandler procedure every time another application (for example. 477 . ToolHandler procedure. you can use the function call: CommandInfo(CMD_INFO_MSG) to retrieve the string sent by the remote application. the external application is the client (active party). and a specific MapBasic application is the server (passive party). MapInfo Professional calls the server's RemoteMsgHandler procedure. Syntax Declare Function RemoteQueryHandler( ) As String Function RemoteQueryHandler( ) As String statement_list End Function statement_list is a list of statements to execute upon receiving a peek request. You can use the End Program statement to terminate a RemoteMsgHandler procedure once it is no longer wanted. called when a MapBasic program acts as a DDE server. and the DDE client performs a “peek” request. The MapBasic procedure then can call the CommandInfo( ) function to retrieve the string corresponding to the execute command. Each time the DDE client sends an execute command.MBX”) as the topic in order to facilitate RemoteMsgHandler functionality. you should be careful not to issue an End Program statement while the RemoteMsgHandler procedure is still needed. In the conversation. “C:\MAPBASIC\DISPATCH. All rights reserved. a spreadsheet or database package) issues an “execute” command. If you run a MapBasic application that includes a procedure named RemoteMsgHandler.RemoteQueryHandler( ) function Description RemoteMsgHandler is a special-purpose MapBasic procedure name that handles inter-application communication. WinChangedHandler procedure. See Also DDEExecute statement. Reference Guide © 2006 MapInfo Corporation. Conversely. Inter-Application Communication Using Windows DDE If a Windows application is capable of conducting a DDE (Dynamic Data Exchange) conversation. DDEInitiate( ) function. SelChangedHandler procedure. WinClosedHandler procedure RemoteQueryHandler( ) function Purpose A special function.

MapInfo Professional automatically calls the RemoteQueryHandler( ) function. The client's peek request is handled synchronously. Example The following example calls the CommandInfo( ) function to determine the item name specified by the DDE client. the client waits until RemoteQueryHandler( ) returns a value. MapBasic 8. RemoteMsgHandler procedure 478 © 2006 MapInfo Corporation. Function RemoteQueryHandler( ) As String Dim s_item_name As String s_item_name = CommandInfo(CMD_INFO_MSG) If s_item_name = "code1" Then RemoteQueryHandler = custom_function_1( ) Else RemoteQueryHandler = custom_function_2( ) End If End Function See Also DDEInitiate( ) function. In other words. Note: The DDE client can peek at the global variables in your MapBasic program. The item name is used as a flag. and it uses the name of your MapBasic application as the DDE topic. if the data you want to expose is already stored in global variables. even if you do not define a RemoteQueryHandler( ) function. To handle peek requests. An external application can initiate a DDE conversation with your MapBasic program. see the MapBasic User Guide. this program decides which value to return based on whether the client specified “code1” as the item name. the external application uses “MapInfo” as the DDE application name.5 .RemoteQueryHandler( ) function Description The RemoteQueryHandler( ) function works in conjunction with DDE (Dynamic Data Exchange). All rights reserved. When the client application issues a peek request. To initiate the conversation. the external application (the client) can issue peek requests to request data from your MapBasic application (the server). include a function called RemoteQueryHandler( ) in your MapBasic application. For an introduction to DDE. Once the conversation is initiated. you do not need RemoteQueryHandler( ). If the client issues a peek request using the name of a MapBasic global variable. MapInfo Professional automatically returns the global's value to the client instead of calling RemoteQueryHandler( ). in other words.

map_layer specifies which map layer(s) to remove.. 2. map_layer . All rights reserved. You cannot use a layer name. call the FrontWindow( ) function or the WindowID( ) function. or the keyword Animate.. Description The Remove Map statement removes one or more layers from a Map window. For example. If no window_id is provided. See Also Add Cartographic Frame statement. ] [ Interactive ] window_id is the integer window identifier of a Map window. a string containing the name of a table. The map_layer parameter can be an integer greater than zero.. see examples below. Alter Cartographic Frame statement. Syntax Cartographic Frame [ Window legend_window_id ] Id frame_id. . frame_id. frame_id is the ID of the frame on the legend. Set Cartographic Legend statement Remove Map statement Purpose Removes one or more layers from a Map window. Create Cartographic Legend statement. legend_window_id is an integer window identifier which you can obtain by calling the FrontWindow( ) function and the WindowID( ) function. 479 . to obtain a window identifier. three frames on a legend would have the successive IDs.Remove Cartographic Frame statement Remove Cartographic Frame statement Purpose Allows you to remove cartographic frames from an existing cartographic legend created with the Create Cartographic Legend statement. Reference Guide © 2006 MapInfo Corporation. as summarized in the following table. frame_id. the statement affects the topmost Map window. and 3.. Syntax Remove Map [ Window window_id ] Layer map_layer [ . 1.

5 . MapBasic 8. 480 © 2006 MapInfo Corporation. A Remove Map statement does not close any tables. MapInfo Professional displays a dialog box that allows the user to save (a workspace). See Also Create Map statement. The new_filespec parameter specifies the file's new name. Description The Rename File statement renames a file. Map statement. Specify “1. The animation layer is removed. The first thematic layer based on the Zones layer is removed. the file must not be open. MapInfo Professional automatically closes the window. Remove Map Layer "Zones" Remove Map Layer "Zones(1)" Remove Map Layer Animate If you include the Interactive keyword. or cancel the layer removal. Set Map statement Rename File statement Purpose Changes the name of a file. All rights reserved. If a Remove Map statement removes the last non-cosmetic layer in a Map window. If new_filespec contains a directory path that differs from the file's original location. new_filespec is a string representing the new name (and. it only affects the number of layers displayed in the Map window. the user is not prompted. To learn how to add an animation layer. the top map layer (other than the Cosmetic layer) is removed. MapInfo Professional moves the file to the specified directory. The Zones layer is removed (assuming that one of the layers in the map is named “Zones”). optionally.Rename File statement Examples Remove Map Layer 1 Descriptions of Examples If you specify “1” (one) as the map_layer parameter. optionally. If you omit the Interactive keyword. Syntax Rename File old_filespec As new_filespec old_filespec is a string representing an existing file's name (and. and if the layer removal will cause the loss of labels or themes. discard the labels and themes. see Add Map statement on page 72. path) for the file. 2" to remove the top two layers. path).

” For example. optionally. Note: This action can invalidate existing workspaces. MapBasic attempts to move the table to the specified directory in addition to renaming the table. QUERY1). Open Table "C:\DATA\CASANFRA. optionally. Reference Guide © 2006 MapInfo Corporation. You could not rename the SF_STRTS table by calling Rename Table. This effect is permanent (unless/until another Rename Table statement is issued). newtablespec is the new name (and. You cannot rename temporary query tables (for example.TAB" The following example renames a table and moves it to a different directory path. If newtablespec contains a directory name. The Rename Table statement cannot rename a table that is actually a “view. Syntax Rename Table table As newtablespec table is the name of an open table. use the Open Table statement’s optional As clause. the location) of the files that make up a table. Any workspaces created before the renaming operation will refer to the table by its previous. you must either save or discard the edits (Commit or Rollback) before renaming. path) for the table. Do not use the Rename Table statement to assign a temporary. All rights reserved. Example The following example renames the table casanfra as sf_hiway.bak" See Also Rename File statement.wor" As "startup. no-longer-applicable name. The newtablespec parameter specifies the table's new name. combining two other tables (SF_STRT1 and SF_STRT2). if a table has unsaved edits. working table name.Rename Table statement Example Rename File "startup. Save File statement Rename Table statement Purpose Changes the names (and. Description The Rename Table statement assigns a new name to an open table. You cannot rename tables that have unsaved edits. a StreetInfo table (such as SF_STRTS) is actually a view. If you need to assign a temporary name.TAB" Rename Table CASANFRA As "SF_HIWAY. 481 . The Rename Table statement renames the physical files which comprise a table.

All rights reserved.TAB" Rename Table CASANFRA As "c:\MAPINFO\SF_HIWAY" See Also Close Table statement. The OnError statement enables an error-handling routine. A Resume label statement tells MapBasic to go to the line identified by the label. A Resume Next statement tells MapBasic to go to the first statement following the statement which generated the error. Note that the label must be in the same procedure. Drop Table statement Reproject statement Purpose Allows you to specify which columns should appear the next time a table is browsed. Restrictions You cannot issue a Resume statement through the MapBasic window. each error-handling routine includes one or more Resume statements. Syntax Resume { 0 | Next | label } label is a label within the same procedure or function. 482 © 2006 MapInfo Corporation. This statement has been deprecated. Resume statement Purpose Returns from an OnError error handler.5 . Description The Resume statement tells MapBasic to return from an error-handling routine. The various forms of the Resume statement let the application dictate which statement MapBasic is to execute after exiting the error-handling routine: A Resume 0 statement tells MapBasic to retry the statement which generated the error. MapBasic 8.Reproject statement Open Table "C:\DATA\CASANFRA. which is a group of statements MapBasic carries out in the event of a run-time error. The Resume statement causes MapBasic to exit the errorhandling routine. Typically.

green. OnError GoTo no_states Open Table "states" Map From states after_mapfrom: . known as an RGB value.. Syntax RGB( red. blue is a numeric expression from 0 to 255. All rights reserved. green and blue components. Accordingly. inclusive. End Program no_states: Note "Could not open States.. and blue—each of which specifies the concentration of one of the three primary colors. OnError statement RGB( ) function Purpose Returns an RGB color value calculated from Red. Error statement. no Map used. green is a numeric expression from 0 to 255. Error$( ) function.. Blue components. blue ) red is a numeric expression from 0 to 255. green.RGB( ) function Example . the RGB( ) function takes three parameters—red.. Return Value Integer Description Some MapBasic statements allow you to specify a color as part of a pen or brush definition (for example. The RGB( ) function lets you calculate such an RGB value. representing a concentration of red. Colors are often defined in terms of the relative concentrations of three components—the red. Each color component should be an integer value from 0 to 255. The RGB value of a given color is calculated by the formula: ( red * 65536) + ( green * 256) + blue Reference Guide © 2006 MapInfo Corporation. Green. 483 . the Create Point statement)." Resume after_mapfrom See Also Err( ) function. MapBasic pen and brush definitions require that each color be specified as a single integer value. representing a concentration of green. representing a concentration of blue.

MAPBASIC. BLUE.color As Integer red = 255 green = 0 blue = 0 color = RGB(red. green. WHITE. See Also Brush clause. 4) 484 © 2006 MapInfo Corporation. If num_expr is larger than the number of characters in the string_expr string. partial As String whole = "Afghanistan" partial = Right$(whole. num_expr is a numeric expression. MAGENTA. Right$( ) returns a null string. Right$( ) returns a copy of the entire string_expr string. you can simply use the identifier RED instead of calling RGB( ). RED. MapBasic 8.blue. CYAN. All rights reserved. saturated red. zero or larger. num_expr ) string_expr is a string expression. beginning at the right end of the string. Example Dim whole. Symbol clause Right$( ) function Purpose Returns part or all of a string. Font clause. The num_expr parameter should be an integer value.green. Return Value String Description The Right$( ) function returns a string which consists of the rightmost num_expr characters of the string expression string_expr. includes Define statements for several common colors (BLACK. blue) ' the RGB value stored in the variable: color ' will represent pure. Example Dim red. If num_expr has a fractional value. MapBasic rounds to the nearest integer.5 . If you want to specify red. GREEN. If num_expr is zero.DEF.Right$( ) function The standard definitions file. Pen clause. and YELLOW). Syntax Right$( string_expr.

Return Value A number of type float between 0 and 1 (exclusive). greater than zero and less than one. Syntax Rnd( list_type ) list_type selects the kind of random number list. The conventional use is of the form Rnd(1). 485 .Rnd( ) function ' at this point. which returns the previous random number generated by the Rnd( ) function. For a given negative value. Example Chknum = 10 * Rnd(1) See Also Randomize statement Reference Guide © 2006 MapInfo Corporation. the Rnd( ) function always returns the same number. This functionality is provided primarily for debugging purposes. in which the function returns a random number. A very uncommon use is a call with a negative list_type value. such as Rnd(-1). Any positive list_type parameter value produces this type of result. Mid$( ) function Rnd( ) function Purpose Returns a random number. A less common use is the form Rnd(0). regardless of whether you have issued a Randomize statement. The sequence of random numbers is always the same unless you insert a Randomize statement in the program. All rights reserved. partial contains the string: "stan" See Also Left$( ) function. This functionality is provided primarily for debugging purposes. Description The Rnd( ) function returns a random floating-point number.

Description If the specified table has been edited. except that command displays a dialog box. but the edits have not been saved. the Rollback statement discards the unsaved edits. All rights reserved. If you then Rollback the QUERY1 table. since the WORLD table is the table on which QUERY1 is based. or the query produces aggregated results. The user can obtain the same results by choosing File > Revert. and browse the selection. if you edit a permanent table (such as WORLD). MapInfo Professional discards any unsaved edits in the permanent table used for the query (except in cases where the query produces a join. MapBasic 8. MapInfo Professional discards any unsaved edits in the WORLD table. Note: When you Rollback a query table. using the Select statement’s Group By clause). make a selection from WORLD. for example.5 . Syntax Rollback Table tablename tablename is the name of an open table. Using a Rollback statement on a linked table discards the unsaved edits and returns the table to the state it was in prior to the unsaved edits. and call the snapshot (something like) QUERY1. For example. Example If keep_changes Then Commit Table towns Else Rollback Table towns End If See Also Commit Table statement 486 © 2006 MapInfo Corporation. MapInfo Professional will “snapshot” the Selection table.Rollback statement Rollback statement Purpose Discards a table's unsaved edits.

All rights reserved. 45) insert into states (obj) values (RotateObject) See Also RotateAtPoint( ) function RotateAtPoint( ) function Purpose Allows an object (not a text object) to be rotated about a specified anchor point. rectangle. If an arc. anchor_point_object ) object represents an object that can be rotated.TAB" map from states select * from States where state = "IN" RotateObject = rotate(selection.Rotate( ) function Rotate( ) function Purpose Allows an object (not a text object) to be rotated about the rotation anchor point. Syntax RotateAtPoint( object. use the Alter Object OBJ_GEO_TEXTANGLE statement. angle is a float value that represents the angle (in degrees) to rotate the object. or rounded rectangle is rotated. the resultant object is converted to a polyline/polygon so that the nodes can be rotated.obj. Reference Guide © 2006 MapInfo Corporation. It cannot be a text object. Return Value A rotated object. angle. To rotate text objects. ellipse. Syntax Rotate( object. It cannot be a text object. Example dim RotateObject as object Open Table "C:\MapInfo_data\TUT_USA\USA\STATES. Description The Rotate( ) function Rotates all object types except for text objects without altering the source object in any way. angle ) object represents an object that can be rotated. 487 .

use the Alter Object OBJ_GEO_TEXTANGLE statement. To rotate text objects. Return Value Float 488 © 2006 MapInfo Corporation. All rights reserved.obj select * from States where state = "NV" obj2 = selection. Syntax Round( num_expr. Return Value A rotated object. ellipse. If an arc. Example dim RotateAtPointObject as object dim obj1 as object dim obj2 as object Open Table "C:\MapInfo_data\TUT_USA\USA\STATES. centroid(obj2)) insert into states (obj) values (RotateAtPointObject ) See Also Rotate( ) function Round( ) function Purpose Returns a number obtained by rounding off another number. Description The RotateAtPoint( ) function rotates all object types except for text objects without altering the source object in any way.obj oRotateAtPointObject = RotateAtPoint(obj1 . MapBasic 8. or rounded rectangle is rotated. 65. round_to is the number to which num_expr should be rounded off.5 .Round( ) function angle is a float value that represents the angle (in degrees) to rotate the object. round_to ) num_expr is a numeric expression.TAB" ] map from states select * from States where state = "CA" obj1 = selection. the resultant object is converted to a polyline/polygon so that the nodes can be rotated. anchor_point_object is an object representing the anchor point which the object nodes are rotated about. rectangle.

and returns the results.6789 y = Round(x. etc. Example Dim x. The Round( ) function rounds the num_expr value to the nearest multiple of the round_to parameter. 489 .01. Syntax RTrim$( string_expr ) string_expr is a string expression. MapInfo Professional rounds to the nearest hundredth.68 See Also Fix( ) function. The precision of the result depends on the round_to parameter. MapInfo Professional rounds to the nearest multiple of 5. and returns the resultant string. Format$( ) function. Example Dim s_name As String s_name = RTrim$("Mary Smith ") Reference Guide © 2006 MapInfo Corporation. Int( ) function RTrim$( ) function Purpose Trims space characters from the end of a string. Return Value String Description The RTrim$( ) function removes any spaces from the end of the string_expr string. All rights reserved. 0. y As Float x = 12345. if round_to is 5.01) ' y now has the value 12345.RTrim$( ) function Description The Round( ) function returns a rounded-off version of the numeric num_expr expression. If round_to is 0. 100) ' y now has the value 12300 y = Round(x. 1) ' y now has the value 12346 y = Round(x.

REPORT. The Run Application statement cannot run an uncompiled application. Run Menu Command statement.Run Application statement ' s_name now contains the string "Mary Smith" ' (no spaces at the end) See Also LTrim$( ) function Run Application statement Purpose Runs a MapBasic application or adds a MapInfo workspace. To do so. Syntax Run Command command 490 © 2006 MapInfo Corporation. Terminate Application statement Run Command statement Purpose Executes a MapBasic command represented by a string. Example The following statement runs the MapBasic application.5 .MBX" The following statement loads the workspace. use the Terminate Application statement. All rights reserved. Run Program statement. MapBasic 8. Description The Run Application statement runs a MapBasic application or loads an MapInfo workspace.wor: Run Application "Parcels. To halt an application launched by the Run Application statement. the file parameter must represent the name of a compiled application file.wor" See Also Run Command statement.MBX: Run Application "C:\MAPBASIC\APP\REPORT. By issuing a Run Application statement. one MapBasic application can run another application. Parcels. Syntax Run Application file file is the name of an application file or a workspace file.

y As Float cmd_string = " x = Abs(y) " Run Command cmd_string However. the following group of statements would not work. 491 . because the variable names x and y appear inside the quotes that delimit the command string: ' this example WON'T work Dim cmd_string As String Dim x. All rights reserved. You cannot use a Run Command statement to issue a Dialog statement. variable names may not appear within the command string. or a comma-separated list of two or more table names. the command string is constructed from an expression that includes a character variable. An application may need to decide at run time (based on feedback from the user) how many table names should be included in the Map From statement.Run Command statement command is a character string representing a MapBasic statement. In the following example. variable names can be used in the construction of the command string. counties_wanted As Logical Open Table "states" Reference Guide © 2006 MapInfo Corporation. the Map From statement can include a single table name. and execute the command through the Run Command statement. For example. rather than being compiled. Also. that is. due to the fact that the command parameter is interpreted at run-time. For example. then executes the statement. The Run Command statement has some restrictions. 'this example WILL work Dim cmd_string As String Dim map_it. Dim cmd_text As String Dim cities_wanted. One way to do this is to construct a text string at run time. variable names may not appear enclosed in quotes. browse_it As Logical Open Table "world" If map_it Then cmd_string = "Map From Run Command cmd_string End If If browse_it Then cmd_string = "Browse * Run Command cmd_string End If " + "world" From " + "world" Example The Run Command statement provides a flexible way of issuing commands that have variablelength argument lists. Description The Run Command statement interprets a character string as a MapBasic statement.

representing a standard menu item or button. 492 © 2006 MapInfo Corporation. MapBasic 8. Can also be used to select a button on a ButtonPad. Run Menu Command statement. WIN_INFO_CLONEWINDOW) See Also Run Application statement. Dim i_map_id As Integer ' First. " + cmd_text End If If cities_wanted Then cmd_text = "cities.DEF (such as M_FILE_NEW). get the ID of an existing Map window ' (assuming the Map window is the active window): i_map_id = FrontWindow( ) ' Now clone the active map window: Run Command WindowInfo(i_map_id. given the window ID of an existing map. All rights reserved. command_ID is a number representing a custom menu item or button.5 . Syntax Run Menu Command { command_code | ID command_ID } command_code is an integer code from MENU. " + cmd_text End If Run Command "Map From " + cmd_text The following example shows how to duplicate a Map window. the Run Command statement executes the string.Run Menu Command statement Open Table "cities" Open Table "counties" cmd_text = "states" ' always include STATES layer If counties_wanted Then cmd_text = "counties. Run Program statement Run Menu Command statement Purpose Runs a MapInfo Professional menu command. as if the user had selected the menu item. The WindowInfo( ) function returns a string containing MapBasic statements.

For example. access Page settings in Options > Preferences > Printer by using the following syntax: RUN MENU COMMAND M_EDIT_PREFERENCES_PRINTER Or Reference Guide © 2006 MapInfo Corporation. In version 6. include the command_code parameter. For example. All rights reserved. For example. The Preferences dialog box contains several buttons.Run Menu Command statement Description To execute a standard MapInfo Professional menu command. a button or a menu command created through a MapBasic program). the following statement selects the Radius Search button: Run Menu Command M_TOOLS_SEARCH_RADIUS To select a custom button or menu command (i. the following MapBasic statement executes MapInfo Professional's File > New command: Run Menu Command M_FILE_NEW To select a standard button from MapInfo's ButtonPads. For example. The value of this parameter must match one of the menu codes listed in MENU. You can use Run Menu Command statement to invoke individual sub-dialog boxes. each of which displays another dialog box. the Run Menu Command statement can execute the MapInfo Professional Help > MapInfo Professional Tutorial on the Web… command..DEF.e. The following statement selects the button. Run Menu Command ID 23 Using MapBasic. Run Menu Command M_HELP_MAPINFO_WWW_TUTORIAL MapInfo Professional's Preferences dialog box is a special case. use the ID clause. specify that button's code (from MENU. if your program creates a custom tool button by issuing a statement such as… Alter ButtonPad ID 1 Add ToolButton Calling sub_procedure_name ID 23 Icon MI_ICON_CROSSHAIR …then the custom button has an ID of 23. 493 .0 and later.DEF). You can access Query > Invert Selection using the following MapBasic command: Run Menu Command M_QUERY_INVERTSELECT. the following statement displays the Map Window Preferences sub-dialog box: Run Menu Command M_EDIT_PREFERENCES_MAP.

Run Command statement. and runs the specified DOS program from there.2do" The following statement issues a DOS command. you could create a custom menu item which calls a handler sub procedure.txt" See Also Run Application statement. and you could make the Run Program statement the final statement in the handler procedure. Syntax Run Program program_spec program_spec is a command string that specifies the name of the program to run. When issuing the Run Program statement. In this case. When you spawn a program through a Run Program statement.com /c dir c:\mapinfo\ > C:\temp\dirlist.exe things. If the program_spec is the character string “COMMAND. you should take precautions to avoid multitasking conflicts. Run Program "command.Run Program statement RUN MENU COMMAND 217 ' if running from MapBasic window See Also Run Application statement.5 . and may also specify command-line arguments.” and instructs Notepad to open the text file THINGS. This multitasking environment could potentially create conflicts. and then type Exit to return to MapInfo. Windows may continue to run other background tasks—including your MapBasic program. Run Menu Command statement 494 © 2006 MapInfo Corporation.COM”. Example The following Run Program statement runs the Windows text editor. For example.2DO. Run Program "notepad. MapBasic invokes a DOS shell. All rights reserved. Run Program statement Run Program statement Purpose Runs an executable program. Thus. One way to avoid such conflicts is to place the Run Program statement at the end of a sequence of events. the user is able to issue DOS commands. Windows continues to control the computer. the MapBasic statements which follow the Run Program statement must not make any assumptions about the status of the spawned program. MapBasic 8. MapBasic invokes the DOS shell without any other program. “Notepad. While the spawned program is running. Description If the specified program_spec does not represent a Windows application.

optionally. These MWS files can be shared across platforms in ways that workspaces cannot. ] ) Default default_window_id As filespec window_id is an integer window identifier for a Map window. Syntax Save File old_filespec As new_filespec [ Append ] old_filespec is a string representing the name (and. etc. The file must not already be open for input/output. filename. Do not use Save File to copy a file that is a component of an open table (for example. and if the file new_filespec already exists.tab. Syntax Save MWS Window ( window_id [ . Example Save File "settings. the contents of the file old_filespec are appended to the end of the file new_filespec.map.. Reference Guide © 2006 MapInfo Corporation. 495 . window_id . the path) of an existing file. Description The Save File statement copies a file. Rename File statement Save MWS statement Purpose This statement allows you to save the current workspace as an XML-based MWS file for use with MapXtreme applications. the file must not be open. use the Commit Table…As statement.Save File statement Save File statement Purpose Copies a file. the path) to which the file will be copied. The Save File statement cannot copy a file to itself. All rights reserved. new_filespec is a string representing the name (and.txt" As "settings. the file must not be open.). To copy a table.bak" See Also Kill statement. If you include the optional Append keyword. optionally. filename..

The sections below show what aspects of our maps can and cannot be saved into an MWS file. All other windows are discarded as MapXtreme applications cannot read that information. Note: You will not be able to read files saved in MWS format in MapInfo Professional 7.8 or later can be validated using schemas supplied with MapXtreme. Graduated symbol themes. MapBasic 8. In MapInfo Professional. The file is valid XML so can also be viewed using any XML viewer or editor. you can set the visibility of a modifier theme without regard to its reference feature layer. Labels based upon expressions. Once your workspace is saved in this format.5 © 2006 MapInfo Corporation. Themes based upon expressions. Dot density themes. Range themes. Bar themes. Ranges. 496 . To ensure that modifiers marked as visible in MapInfo Professional display in tools like Workspace Manager. Individual value themes. Label and label edit information. so you can turn the visibility of the main reference layer off but still display the theme. Style overrides. Map resize method. Map size as pixel width and height. Edited labels Queries referenced by map windows. MWS files created with MapInfo Professional 7. All rights reserved. Coordinate system information. Map center and zoom settings. Raster layer overrides. Description MapInfo Professional enables you to save the maps in your workspace to an XML format for use with MapXtreme applications. Layer list with implied order. It is important to note that many MapBasic statements and functions do not translate to MWS format. In MapXtreme. Individual Value) are only drawn if the reference feature layer is visible. When saving a workspace to MWS format.Save MWS statement default_window_id is an integer window identifier for the Map window to be recorded in the MWS as the default map. What is Saved in the MWS The following information is included in the MWS workspace file: • • • • • • • • • • • • • • • • • • Tab files' name and alias.8 or later. only the map windows and legends are saved. it can be opened with the Workspace Manager utility that is included in the MapXtreme installation or with an application developed using MapXtreme. For detailed listing of the compatibilities between MapBasic and MISQL see the MapInfo Professional User Guide. the modifier themes (Dot Density. we force the visibility of the reference feature layer so that its modifier themes display.

call a function such as the FrontWindow( ) function or the WindowID( ) function. What is Not Saved to the MWS The following information is not saved in the MWS workspace file: • • • • • Any non-map windows (browsers. Hot links for labels and objects. Printer setup information. autoscroll.. Prism maps). Grid themes as MapXtreme grid layers with a style override. Reference Guide © 2006 MapInfo Corporation. corresponds to choosing File > Save Window As. Themes and label expressions based upon a single attribute column. Any table that is based on a query without a window referencing them. charts. Layout. • • • • • Queries without a map window referencing them. Line direction arrows.Save Window statement • • • Pie themes. Syntax Save Window window_id As filespec Type filetype [ Width image_width [ Units paper_units ] ] [ Height image_height [ Units paper_units ] ] [ Resolution output_dpi ] [ Copyright notice [ Font. Statistics. Snap mode. 497 .. or Ruler window. Graph. area. 3D map windows. See Also Save Workspace statement Save Window statement Purpose Saves an image of a window to a file. and smart pan settings. Queries with “sub-select” statements. Export options. Layers based on queries that includes “sub-select” statements. Distance. ] ] window_id is an integer Window ID representing a Map. Legend. Note: A complex expression includes any operator or multiple referenced tables. Note: A “sub-select” statement is any Select statement nested inside another Select statement. Whether object nodes are drawn or not. Info. All rights reserved. to obtain a window ID. • • • Any theme that is based upon computed columns. or XY and military grid units. redistricters.

“JP2” specifies JPEG 2000 format. See the example below. “TIFFLZW” specifies TIFFLZW format. The effect is comparable to the user choosing File > Save Window As. To include a copyright notice on the bottom of the image. filetype is a string representing a file format: • • • • • • • • • • • • “BMP” specifies Bitmap format. Layout. except that the Save Window statement does not display a dialog box. For Legend. Info. Examples This example produces a Windows metafile: Save Window i_mapper_ID As "riskmap. “PSD” specifies Photoshop 3. The Font clause specifies a text style. “cm” for centimeters).Save Window statement filespec is a string representing the name of the file to create. The Font clause specifies a text style in the copyright notice. Error number 408 is generated if the export fails due to lack of memory or disk space. use the optional Copyright clause.5 . “JPEG” specifies JPEG format. the default size is the size needed to represent all of the data in the window. Use the optional Width and Height clauses to specify a nondefault image size. or Graph windows. “TIFFCMYK” specifies TIFF CMYK format. it will appear at the bottom of the image. image_height is a number that specifies the desired image height. “WMF” specifies Windows Metafile format. notice is a string that represents a copyright notice. Note that specifying very large image sizes increases the likelihood of this error. image_width is a number that specifies the desired image width. “EMF” specifies Windows Enhanced Metafile format. “PNG” specifies Portable Network Graphics format. specify a Copyright clause with an empty string (""). MapBasic 8. the default image size is the size of the original window. paper_units is a string representing a paper unit name (for example.0 format. or Ruler windows. Description The Save Window statement saves an image of a window to a file. output_dpi is a number that specifies the output resolution in DPI (dots per inch). “TIFF” specifies TIFF format. Statistics.wmf" Type "WMF" 498 © 2006 MapInfo Corporation. To eliminate the default notice. For Map. “TIFFG4” specifies TIFFG4 format. Resolution allows you to specify the dpi when exporting images to raster formats. “GIF” specifies GIF format. All rights reserved.

The Chr$( ) function is used to insert the copyright symbol.bmp" Type "BMP" Copyright "Copyright " + Chr$(169) + " 1996.Save Workspace statement This example shows how to specify a copyright notice. To load an existing workspace file. Description The Save Workspace statement creates a workspace file that represents the current MapInfo Professional session. Syntax Save Workspace As filespec filespec is a string representing the name of the workspace file to create. attribute ) sequence_number is an integer number. except that the Save Workspace statement does not display a dialog box. from 1 to the number of objects located. The effect is comparable to the user choosing File > Save Workspace. Save Window i_mapper_ID As "riskmap. Reference Guide © 2006 MapInfo Corporation. attribute is a small integer code from the table below. Example Save Workspace As "market.wor" See Also Run Application statement SearchInfo( ) function Purpose Returns information about the search results produced by SearchPoint( ) or SearchRect( ). MapInfo Corp. Syntax SearchInfo( sequence_number. 499 . use the Run Application statement." See Also Export statement Save Workspace statement Purpose Creates a workspace file representing the current MapInfo Professional session. All rights reserved.

DEF) in the following table: attribute code SEARCH_INFO_TABLE SearchInfo( ) returns: String value: the name of the table containing this object. if the user uses the rectangle tool. All rights reserved. In either case. call SearchInfo( ) to process the search results. The sequence_number argument is an integer number. To manually free the memory used by search results. depending on attribute. the program calls the SearchRect( ) function.def" Sub Main Sub tool_sub Sub Main Create ButtonPad "Searcher" As 500 © 2006 MapInfo Corporation. Note that search results remain in memory even after the user closes the window or the tables associated with the search. perform a search which you know will fail (for example. Include Include Declare Declare "mapbasic. therefore.def" "icons. MapBasic 8. You can use this rowID number in a Fetch statement or in a Select statement’s Where clause. this program calls the SearchPoint( ) function. If an object is from a Cosmetic layer.SearchInfo( ) function Return Value String or integer. 0). Error Conditions ERR_FCN_ARG_RANGE error is generated if sequence_number is larger than the number of objects located. SEARCH_INFO_ROW Search results remain in memory until the application halts or until you perform another search. this program calls SearchInfo( ) to determine which object(s) the user chose. Integer value: this row's rowID number. plus another set of search results for MapInfo Professional itself (for commands entered through the MapBasic window). 1 or larger. Description After you call SearchRect( ) or SearchPoint( ) to search for map objects. Example The following program creates two custom tool buttons.5 . If the user uses the point tool. search at location 0. you should process search results immediately. The attribute argument must be one of the codes (from MAPBASIC. 1 or larger). this string has the form “CosmeticN” (where N is a number. The number returned by SearchPoint( ) or SearchRect( ) is the maximum value for the sequence_number. MapInfo Professional maintains a separate set of search results for each MapBasic application that is running.

" End Sub Sub tool_sub ' This procedure is called whenever the user uses ' one of the custom buttons on the Searcher toolbar. Else Print Chr$(12) If CommandInfo(CMD_INFO_TOOLBTN) = 2 Then Print "Rectangle: x1= " + x + ". y2 As Float. i_row_id. WIN_INFO_TYPE) <> WIN_MAPPER Then Note "This tool only works on Map windows. x = CommandInfo(CMD_INFO_X) y = CommandInfo(CMD_INFO_Y) If CommandInfo(CMD_INFO_TOOLBTN) = 1 Then ' Then the user is using the point-mode tool. y= " + y Reference Guide © 2006 MapInfo Corporation. x2. y) Else ' The user is using the rectangle-mode tool. y. x." Exit Sub End If ' Determine the starting point where the user clicked. i.SearchInfo( ) function ToolButton Calling tool_sub ID 1 Icon MI_ICON_ARROW Cursor MI_CURSOR_ARROW DrawMode DM_CUSTOM_POINT HelpMsg "Click on a map location\nClick a location" Separator ToolButton Calling tool_sub ID 2 Icon MI_ICON_SEARCH_RECT Cursor MI_CURSOR_FINGER_LEFT DrawMode DM_CUSTOM_RECT HelpMsg "Drag a rectangle in a map\nDrag a rectangle" Width 3 Print "Searcher program now running. x. ' Determine what objects are within the rectangle. i_found. s_table As Alias i_win_id = FrontWindow( ) If WindowInfo(i_win_id. y2) End If If i_found = 0 Then Beep ' No objects found where the user clicked." Print "Choose a tool from the Searcher toolbar" Print "and click on a map. 501 . y1= " + y Print "x2= " + x2 + ". i_win_id As Integer. All rights reserved. y2= " + y2 Else Print "Point: x=" + x + ". x2. Dim x. y. ' determine how many objects are at the chosen point. x2 = CommandInfo(CMD_INFO_X2) y2 = CommandInfo(CMD_INFO_y2) i_found = SearchRect(i_win_id. i_found = SearchPoint(i_win_id.

representing the number of objects found. latitude) Return Value Integer. i_row_id = SearchInfo(i. longitude) y is a y-coordinate (for example. All rights reserved. s_table = SearchInfo(i. 502 © 2006 MapInfo Corporation. SEARCH_INFO_ROW) If Left$(s_table. SearchRect( ) function SearchPoint( ) function Purpose Searches for map objects at a specific x/y location. even the Cosmetic layer (if it is currently selectable). 8) = "Cosmetic" Then Print "Object in Cosmetic layer" Else ' Fetch the row of the object the user clicked on. y ) map_window_id is a Map window's integer ID number x is an x-coordinate (for example. Description The SearchPoint( ) function searches for map objects at a specific x/y location.5 . The return value indicates the number of objects found.SearchPoint( ) function End If ' Process the search results.col1" Print s_table End If Next End If End Sub See Also SearchPoint( ) function. SEARCH_INFO_TABLE) ' Get the row ID number of the object that was a hit. The search applies to all selectable layers in the Map window. Syntax SearchPoint( map_window_id. MapBasic 8. x. For i = 1 to i_found ' Get the name of the table containing a "hit". Fetch rec i_row_id From s_table s_table = s_table + ".

nor does it affect the current selection. Note: This function does not select any objects. The search behavior matches the behavior of MapInfo Professional's Marquee Select button: If an object's centroid falls within the rectangle. Points or linear objects that are very close to the location are included in the search results. use the Create ButtonPad statement or the Alter ButtonPad statement to create a custom ToolButton. even the Cosmetic layer (if it is currently selectable). Syntax SearchRect( map_window_id. y1. x2. representing the number of objects found. 503 . Instead. this function builds a list of objects in memory. See Also SearchInfo( ) function. call the SearchInfo( ) function to process the search results. Return Value Integer. even if the user did not click on the exact location of the object. identical to the tolerance allowed by MapInfo Professional's Info tool. x2. x1. see the SearchInfo( ) function on page 499. The return value indicates the number of objects found. The search allows for a small tolerance. Use DM_CUSTOM_POINT as the button's draw mode. After calling SearchRect( ) you call SearchInfo( ) function to process the search results. All rights reserved. After calling SearchPoint( ). this function builds a list of objects in memory. y2 are coordinates that specify the opposite corner of a rectangle.SearchRect( ) function This function does not select any objects. Reference Guide © 2006 MapInfo Corporation. Within the button's handler procedure. y1 are coordinates that specify one corner of a rectangle. y2 ) map_window_id is a Map window's integer ID number. Instead. To allow the user to select an x/y location with the mouse. call the CommandInfo( ) function to determine the x/y coordinates. nor does it affect the current selection. x1. The search applies to all selectable layers in the Map window. the object is included in the search results. Example For a code example. Description The SearchRect( ) function searches for map objects within a rectangular area. SearchRect( ) function SearchRect( ) function Purpose Searches for map objects within a rectangular area.

see the SearchInfo( ) function on page 499. call CommandInfo( ) function to determine the x/y coordinates. Return Value Integer Description The Seek( ) function returns MapBasic's current position in an open file. Seek( ) returns the byte position of the next byte to be read from or written to the file. If the file was opened in binary mode. SearchPoint( ) function Seek( ) function Purpose Returns the current file position. See Also SearchInfo( ) function. Open File statement. The integer value returned by the Seek( ) function represents a file position.Seek( ) function To allow the user to select a rectangular area with the mouse. Seek( ) returns a record number (the next record to be read or written). Error Conditions ERR_FILEMGR_NOTOPEN error is generated if the specified file is not open. See Also Get statement.5 . MapBasic 8. Put statement. All rights reserved. this is the same number specified in the As clause of the Open File statement. The filenum parameter represents the number of an open file. Within the button's handler procedure. use the Create ButtonPad statement or the Alter ButtonPad statement to create a custom ToolButton. If the file was opened in random-access mode. Seek statement 504 © 2006 MapInfo Corporation. Example For a code example. Syntax Seek( filenum ) filenum is the number of an open file. Use DM_CUSTOM_ RECT as the button's draw mode.

Description SelChangedHandler is a special MapBasic procedure name. All rights reserved. called automatically when the set of selected rows changes. the position parameter specifies a record number. indicating the desired file position. Seek( ) function. If the file was opened in a sequential access mode. Put statement. Description The Seek statement resets the current file position of an open file. to prepare for the next file input/output operation. The sleeping application remains in memory until the application Reference Guide © 2006 MapInfo Corporation. the position parameter specifies a specific byte position. position filenum is an integer value. position is an integer value. a position value of one represents the very beginning of the file. If the file was opened in Random access mode. Print # statement. Write # statement SelChangedHandler procedure Purpose A reserved procedure.Seek statement Seek statement Purpose Sets the current file position. File input/output operations which follow a Seek statement will read from (or write to) the location specified by the Seek. 505 . Syntax Seek [ # ]filenum. See Also Get statement. indicating the number of an open file. Input # statement. Syntax Declare Sub SelChangedHandler Sub SelChangedHandler statement_list End Sub statement_list is a list of statements to execute when the set of selected rows changes. the application “goes to sleep” when the Main procedure runs out of statements to execute. If the user runs an application with a procedure named SelChangedHandler. Open File statement.

Be careful not to issue an End Program statement while the SelChangedHandler procedure is still needed. . MapBasic 8. Within the SelChangedHandler procedure. 2 if one row was removed from the selection. you can use the End Program statement to terminate a SelChangedHandler procedure once it is no longer wanted.. FALSE otherwise. Also provides the ability to sort and sub-total data.3 if multiple rows were added to the selection. the application is completely removed from memory. Syntax Select expression_list From table_name [ . See Also CommandInfo( ) function. the SelChangedHandler procedure should not issue statements such as a Note statement. Print statement. When the Selection table changes. In other words. Integer value: The number of the row which was selected or deselected (only applies if a single row was selected or de-selected).Select statement executes an End Program statement. ] [ Into results_table [ [ Group By column_list [ Order By column_list [ Where expression_group ] Noselect ] ] ] ] 506 © 2006 MapInfo Corporation. MapInfo Professional automatically calls the SelChangedHandler procedure whenever the set of selected rows changes. one after another. Thus. temporary table.5 . CMD_INFO_ROWID CMD_INFO_INTERRUPT When any procedure in an application executes the End Program statement. you can obtain information about recent changes made to the selection by calling CommandInfo( ) function with one of the following codes: attribute code CMD_INFO_SELTYPE CommandInfo( attribute ) returns: 1 if one row was added to the selection. MapBasic automatically calls all sleeping SelChangedHandler procedures. A SelChangedHandler procedure should not take actions that affect the GUI “focus” or reset the current window. SelectionInfo( ) function Select statement Purpose Selects particular rows and columns from one or more open tables.. Multiple MapBasic applications can be “sleeping” at the same time. All rights reserved. or Dialog statement. and treats the results as a separate. 4 if multiple rows were de-selected. Logical value: TRUE if the user interrupted a selection process by pressing Esc. As long as the application remains in memory.

or combine columns from two or more tables into a single results table. The MapBasic Select statement is modeled after the Select statement in the Structured Query Language (SQL). The asterisk signifies that all columns should be included in the results. 507 . All rights reserved. Generally speaking. For example. you may already be familiar with the Select statement. Description The Select statement provides MapBasic programmers with the capabilities of MapInfo Professional's Query > SQL Select dialog box. Select clause This clause dictates which columns MapBasic should include in the results table. The simplest type of expression_list is an asterisk character (“*”). making it easy to browse only the records which met the criteria (this is sometimes referred to as filtering). One Select statement might apply a test to a table. Note that these clauses are not mutually exclusive. The Select statement format includes several clauses. The Select statement serves a variety of different purposes. if you wish to use a Select statement to subtotal the values in the table. Alternately. separated by the keywords AND or OR. Thus.columnname) in a Select statement may only refer to tables that are listed in the Select statement's From clause. Following a Select statement. a MapBasic program can use the SelectionInfo( ) function to examine the current selection. one Select statement may include all of the optional clauses. a MapBasic program—or. and selects some or all of the rows from said table(s). The Select statement then treats the group of selected rows as a results table. you should include an Order By clause. Note. Select might be used to calculate totals or subtotals for an entire table. tablename. results_table is the name of the table where query results should be stored. if you want MapBasic to sort the results of the Select statement. for that matter. After issuing a Select statement. if you have used SQL-oriented database software. expression_group is a list of one or more expressions. For example: if you wish to use a Select statement to set up a filter. a Select statement may only incorporate the column expression STATES. column_list is a list of one or more names of columns. a Select statement queries one or more open tables.OBJ if the table STATES is included in the statement's From clause. a MapInfo Professional user—can treat the results table as any other MapInfo table. Select can also: sort the rows of a table. separated by commas. The statement: Reference Guide © 2006 MapInfo Corporation. you should include a Where clause. you should include a Group By clause. most of which are optional.Select statement expression_list is a comma-separated list of expressions which will comprise the columns of the Selection results. table_name is the name of an open table. however. The nature and function of a Select statement depend upon which clauses are included. derive new column values from one or more existing columns. that MapBasic's Select statement includes geographic capabilities that you will not find in other packages. Selection is the default name of this table (although the results table can be assigned another name through the Into clause). Column expressions (for example.

the resultant table will include a column which indicates what type of object (if any) is attached to that row. rather than the results of a previous query. MapBasic function calls and/or operators are used to derive some new value from one or more of the column names. this alias would appear. Round(population. the first column in the results table will contain values from the world table's name column. Each expression in the expression_list clause can be explicitly named by having an alias follow the expression. If you are doing a multiple-table join. that groups of two or more expressions must be connected by the keywords And or Or. object From world ' this won't work! From clause The From clause specifies which table(s) to select data from. a twoexpression Where clause might read like this: Where Income > 15000 And Income < 25000 508 © 2006 MapInfo Corporation. but not both. After MapBasic carries out the above Select statement.5 .1000000) "Millions" From world Any mappable table also has a special column. For example. If an asterisk appears following the keyword Select. called object (or obj for short). then that asterisk must be the only thing in the expression_list. For example. each of which represents one column to include in the results table. rather than being comma-separated.1000000) From world The expression_list above consists of two expressions. All rights reserved. The second column in the results table will contain values from the world table's population column. and the second of which is a function call (Round( )) which operates on another column (population). Typically. separated by commas. at the top of a Browser window displaying the appropriate table. If you include the column expression obj in the expression_list. the first of which is a simple column name (country). The expression_list may include either an asterisk or a list of column expressions. Alternately. MapBasic 8. the following statement would not be legitimate: Select *. rounded off to the nearest million. the following Select statement specifies an expression_list clause with two expressions: Select country. In other words.Select statement Select * From world tells MapBasic to include all of the columns from the “world” table in the results table. Note. the expression_list clause can consist of a list of expressions. Any expression can be used (see Expressions section below). The following statement would assign the field alias “Millions” to the second column of the results table: Select country. however. each of these expressions involves the names of one or more columns from the table in question. Where clause One function of the Where clause is to specify which rows to select. the tables you are selecting from must be base tables. Very often. for example.Round(population.

some of the products may be sold out. the expression “Not object” can be used to single out records which do not have graphical objects attached.state.field. The following query selects any customer record whose state column contains “NY. and “orders” is a table of the orders we have for our products.state contains two-letter state abbreviations which match the abbreviations in the column States. whereas the Or operator makes the clause less restrictive (MapBasic will select a record if either of the expressions evaluates to TRUE). Conversely. Where States. Where states. In the next example. for the sake of allowing the Where clause to test if a given condition is true for all of the values in the subset.” The column City_1k. based on which products are currently in stock. The task here is to figure out which orders we can fill. and the Where clause must include an expression which tells MapBasic how to join the two tables.obj A Where clause can incorporate a subset of specific values by including the Any or All keyword.obj Contains City_1k. we use two tables: “products” is a table of the various products which our company sells. you can specify a geographic operator to tell MapInfo Professional how to join the two tables. the All keyword defines a subset. 509 . Select * From customers Where state = Any ("NY".” Select * From orders Where partnum <> All(Select partnum from products where not instock) Reference Guide © 2006 MapInfo Corporation. Conversely. All rights reserved. “select all orders which are not among the list of items that are currently sold out. for the sake of allowing the Where clause to test if a given expression is TRUE for any of the values in the subset. the statement must include a Where clause. to produce what is known as a subquery. where the two fields have corresponding values. a Where clause can test geographic aspects of each row in a mappable table. This query uses the logic. By referring to the special column name object. For example.” The Any( ) function functions the same way as the SQL “IN” operator. the following Where clause would tell MapBasic to select only those records which are currently un-geocoded: Where Not Object If a Select statement is to use two or more tables. At any given time.Select statement Note that the And operator makes the clause more restrictive (both conditions must evaluate as TRUE for MapBasic to select a record).state = City_1k.” or “PA. "MA". Such a join-related expression typically takes the form Where tablename1.” “MA. The following example shows how you might join the tables “States” and “City_1k.field = tablename2. "PA") A Where clause can also include its own Select statement.state Alternately. The Any keyword defines a subset.

name From vars Where lead.5 . and the main Select statement's Where clause tests for inclusion in that set of values. An example: ' Note: the following statement. In other words. the keywords Not In may be used in place of the operator sequence: <> All. MapBasic 8. the inner query is reprocessed for each row in the outer table. which uses the In keyword: Where state In ("NY". this produces our subselect. the resulting table is named Selection. Additionally. Alternately. the keyword Select appears a second time. through the use of other SQL-compatible database packages. Thus. A Select statement can use the keyword In in place of the operator sequence = Any. which uses the Any keyword: Where state = Any ("NY". non-nested subqueries. and call the snapshot QUERYn (for example. The Where clause of the main query then uses All( ) function to access the list of unavailable parts.name) This limitation is primarily of interest to users who are already proficient in SQL queries. MapBasic's Select statement does not support “correlated subqueries. a sub-select might use an aggregate operator to produce a single result. the net result of the following Select statement is that all records having higher-than-average population are selected. "MA". will NOT work in MapBasic Select * from leads Where lead. QUERY1). Note: A single Select statement may not include multiple. "PA") is equivalent to the following Where clause. the following Where clause. "MA".” A correlated subquery involves the inner query referencing a variable from the outer query. If no Into clause is specified. Accordingly. In the example above. Note that when a subsequent operation references the Selection table. The sub-select builds a list of the parts that are currently not in stock. Into clause This optional clause lets you name the results table. Select * From states Where population > (Select Avg(population) From states) MapInfo Professional also supports the S