Accessing the mapbasic window, Running a mapbasic program – Pitney Bowes MapInfo Professional User Manual

Page 447

Advertising
background image

that the MapBasic window is also a useful tool to MapInfo Professional users for doing certain tasks
such as complex selections and queries based on object information.

The MapBasic window is limited to selected commands from the MapBasic programming language. The
MapBasic window can take commands line by line. It does not include the capability for looping,
interapplication communication, and other more complex commands. If you find yourself using the
MapBasic window often, you may want to consider transferring your code to a MapBasic application that
will automate the process.

Accessing the MapBasic Window

To access the MapBasic window, on the Options menu, click Show MapBasic Window. The MapBasic
window displays on your screen. As with any other window, you may resize it or move it to a new location.
The window allows you to enter MapBasic code or to view MapBasic code as it is generated by MapInfo
Professional.

To see how MapInfo Professional carries out a select statement:

1. Open the MapBasic window and then open the WORLD table.

2. On the Query menu, click Select.

3. Type in the expression Pop_1994 > 1000000. Make sure that the Browse Results box is checked.

4. Click OK. The syntax for these commands appears in the MapBasic window as follows:

Open Table "C:\MAPINFO\DATA\WORLD\WORLD.tab" Interactive
Map From World
select * from World where Pop_1994 > 1000000 into Selection
browse * from Selection

The first line is a result of opening the WORLD table. The second line of code is written automatically
because the WORLD table displays in a Map window by default. The third line is the syntax for the select
statement. The fourth line is the result of checking the Browse results box.

You can also enter MapBasic commands into the MapBasic window. Position your cursor under the
browse from Selection line. Type the following:

Map from Selection

Press Enter after the line, and the command executes. You should see your selection displayed in a
Map window.

As stated before, the MapBasic window was primarily designed to assist MapBasic programmers. You
can statements and functions in the MapBasic window such as Buffer( ) function or Insert statement.

Refer to the MapBasic Reference, which is located in the Documentation subfolder of your installation
directory to find the appropriate usage and syntax for these statements and functions. It provides a
comprehensive guide to MapBasic programming statements and functions along with examples.

Running a MapBasic Program

Use Run in the Tools menu to run a MapBasic program. MapBasic is a programming language that you
can use to customize or automate Maplnfo Professional. To create MapBasic applications, you need
the MapBasic compiler, which is a separate product. However, you do not need the MapBasic compiler
to run a completed MapBasic application.

MapInfo Professional comes with an assortment of completed MapBasic applications. Some examples
include:

• Symbol application (SYMBOL.MBX). Creates custom symbol shapes.

• Scale Bar application (SCALEBAR.MBX). Annotates a map with a distance scale.

• Named Views application (NVIEWS.MBX). Assigns a name to the current map view and use that name

to return to that view later.

447

MapInfo Professional User Guide

Chapter 17: Specialized Topics in MapInfo Professional

Advertising