Chapter 22 Using Mapbasic
Open the MapBasic window
To open the MapBasic window, select Options "Display the MapBasic window, the MapBasic window is displayed on the screen.
Like other windows, you can change its size or move to a new location. You can enter the MapBasic code in this window or read the MapBasic code when you integrate MapInfo. To know how MapInfo performs a selected statement, open the MapBasic window, and open the world map table. Select the query "Select. Type of expression: POP_1994> 1000000. Determine the result browsing window is selected, click OK. The syntax of these instructions will be displayed in the MapBasic window:
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 open a world table; the second line is automatically generated because the world table is displayed in the map window; the third line is the syntax of the selection statement; the fourth line is the result of checking the browser. You can also enter the MapBasic statement in the MapBasic window. Place your cursor under the selected statement, type the following statement
Map from Selection
Tap the carriage back at the end of the line, the command is executed. You will see the display you choose in the map window. As mentioned above, the MapBasic window initially serves to assist MapBasic programmers. The remaining parts of this chapter will focus on the most useful MapBasic commands for MapInfo users.
Buffer () function
purpose
Returns a regional object representing the buffer (in a certain range of buffer regions in a range of objects)
grammar
Buffer (InputObject, Resolution, Width, Unit_name)
InputObject is an object expression
Resolution is a small integer value representing the number of nodes in each angle
Width is a buffer value represents the radius of the buffer. If the width is negative, if the input object is a closed object, the returned object is a slightly smaller object than the original object.
Unit_name (unit name) refers to the unit (such as MI referring to mile, km refers to the metering unit)
return value
Return to a zone
description
Buffer () function returns a region representing the buffer
The buffer () function can only operate an object at a time. If you create an item set,? ? ? Use created an object as a buffer statement.
FrontWindow () function
purpose
Returns an integer tag of the activation window. This allows you to change the front window after the MapBasic window.
grammar
FrontWindow ()
return value
Integer integer
description
FrontWindow () function returns the front file window (map, browser, graphics, layout output)
example
Print "The Window ID IS" STR $ (FrontWindow ()).
EXAMPLE
Print "The Window ID IS" STR $ (FrontWindow ()).
CreateCircle () function
purpose
Returns an object value representative
grammar
CreateCircle (X, Y, Radius)
X is a single precision value, representing the center of X-axis (such as longitude)
Y is a single precision value, representing the Y-axis position of the center (such as latitude)
RADIUS is a single precision value, representing the radius of the center
return value
Object
object
description
The CreateCircle () function returns an object value X, Y parameter using MapBasic, is using the coordinate system that is used by default. MapBasic uses latitude and longitude coordinate systems, although the SET COORDSYS statement can reset MapBasic to use a different coordinate system. Note that the MapBasic coordinate system is independent of the coordinate system of any Map window. The radius of the RADIUS parameter marker, regardless of the MapBasic now. MapBasic uses miles as the default distance unit, but uses the Set Distance Units statement to set MapBasic using different distance units. The circle will use the currently selected brush mode. Creating a circle assigned to object variables through the CreateCircle () function, stored in a row of an existing table (by update refresh statement), or insert into a new row (by inserting statements)
Note: Before creating an object in a layout window, you must first declare the set coordsys layout statement.
CreateLine () function
purpose
Returns the object value representing a line
grammar
CreateLine (x1, y1, x2, y2)
X1 is a single precision value, the X-axis position of the starting point of the line (such as longitude)
Y1 is a single precision value, the Y-axis position of the starting point of the line (such as latitude)
X2 is a single precision value, the representative line end point X-axis position (such as longitude)
Y2 is a single precision value, the Y-axis position of the end point of the line (such as latitude)
return value
Object
description
CreateLine () function returns an object value representing a line
X, Y parameters use MapBasic coordinate systems that are using by default. MapBasic uses a latitude and longitude coordinate system that can reset MapBasic to use a different coordinate system via the SET COORDSYS statement. Note that the MapBasic coordinate system is independent of the coordinate system of any Map window. Createline () function can create a line assigned to the object variable, store in a row of an existing table (through the Update refresh statement), or insert into a new row (by inserting statements)
Note: Before you create an object in a layout window, you must first declare the set coordsys layout statement.
CreatePoint () function
purpose
Returns an object value of the representative point
grammar
CreatePoint (x, y)
X is a single precision value, represents the X-axis position (such as longitude)
Y is a single precision value, represents the Y-axis position (such as latitude)
x is a float value, representing an x_position (e.g. longitude)
y is a float value, representing a y_position (e.g. latitude)
return value
Object
description
CreatePoint () function returns an object value of the representative point
X, Y parameters use MapBasic coordinate systems that are using by default. MapBasic uses latitude and longitude coordinate systems, but the SET COORDSYS statement can reset MapBasic to use a different coordinate system. Note that the MapBasic coordinate system is independent of the coordinate system of any Map window. Click to use the currently selected symbol. Creating a circle assigned to object variables through the CreateCircle () function, stored in a row of an existing table (by update refresh statement), or insert into a new row (by inserting statements)
Note: Before creating an object in a layout window, you must first declare the set coordsys layout statement.
CreateText () function
purpose
Returns a text object syntax for a special map window
CreateText (Window_ID, X, Y, Text, Angle, Anchor, Offset)
Window_id is an integer window sign representing a map window
X, Y is a single precision value, representing the X / Y axis position placed in text
Text is a character value, representing the text of the text object
Angle is a single precision value, representing the angle of rotation, such as horizontal text, input 0
Anchor is an integer value from 0 to 8, controlling the relative position of text and anchoring position.
Location Enter a line in the following code
Text location digital code
Center 0
Left 1
Upper 2
Upper right 3
Left 4
Middle right 5
Lower left 6
Next 7
Lower right 8
Offset is an integer value from 0 to 50, represents the offset value (pixel) of text and anchor position, when the anchor is 0, OFFSET can ignore (in place)
return value
Object
description
CreateText () function returns a text object for a special map window
Text object uses an existing font form
When the text is created, the word height is controlled by the existing font. However, when the text is created, its size relies on the zoom of the map window, and the aware will make the text significantly.