Introduction To MapBasic
Introduction To MapBasic
Introduction To MapBasic
non-programmer
Jim Regan
Senior Consultant
Pitney Bowes Software – Global Services
Who am I ?
• Jim Regan
• Senior Consultant, Pitney Bowes Software, Global Services
• 14+ years at MapInfo/Pitney Bowes Software
• Training
• Developer Services
• Professional Services
• Global Services
• [email protected]
Agenda
• What is MapBasic
• MapBasic applications
What Is MapBasic?
• MapBasic Programmers
What you can do with MapBasic
• Add functionality
MapBasic in MapInfo Professional
• SURPRISE!!!!!
You have already been using MapBasic by just using
MapInfo Professional
• Every time you open a workspace, you are actually
running a series of MapBasic commands
• The menus are created through MapBasic commands
• The MapBasic window shows “behind the scenes”
commands
Where Does MapBasic Exist
• MapBasic Window
• Accessed via the Options > Show MapBasic Window menu
option in MapInfo Professional
• MapInfo Workspaces
• *.WOR
• MapInfo Menu File
• C:\Program Files\MapInfo\Professional\MAPINFOW.MNU
• MapBasic Applications
• *.MB - MapBasic source code
• *.MBX - Compiled MapBasic executable file
MapBasic Window
MapBasic Window
• Text file
• Series of MapBasic commands to open tables and arrange
data views
• Easy to read* (Individual descriptions may vary)
• Useful to learn MapBasic syntax and statements
• Consider copying / pasting MapBasic statements from a
workspace into a program or MapBasic window
• Consider modifying a Workspace to perform additional
commands when it is loaded
Workspaces - 9D_MapWorld2008.wor ( 1 of 2 )
!Workspace
!Version 600
!Charset WindowsLatin1
Open Table "Data\gazmaj" As gazmaj Interactive
Open Table "Data\ocean" As ocean Interactive
Open Table "Data\STATES" As STATES Interactive
Open Table "Data\World" As World Interactive
Set Window MapBasic
Position (2.59375,6.22917) Units "in"
Width 7.22917 Units "in" Height 1.5625 Units "in"
Open Window MapBasic
Map From gazmaj,STATES,World,ocean
Position (0.0520833,0.0520833) Units "in"
Width 10.3438 Units "in" Height 6.85417 Units "in"
Set Window FrontWindow() ScrollBars Off Autoscroll On
Set Map
CoordSys Earth Projection 1, 62
Center (-73.46802886,44.1447105)
Zoom 2633.012886 Units "mi"
Preserve Zoom Display Zoom
Distance Units "mi" Area Units "sq mi" XY Units "degree"
Set Map
Layer 1
Display Global
Workspaces - 9D_MapWorld2008.wor ( 2 of 2 )
Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (34,16711680,3,"MapInfo Symbols",256,0) Line (1,2,0) Font
("Arial",0,9,0)
Label Line Arrow Position Right Font ("Arial",0,9,0) Pen (1,2,0)
With Place_Name
Parallel On Auto Off Overlap Off Duplicates On Offset 2
Visibility On
Layer 2
Display Global
Global Pen (1,2,7368816) Brush (2,16777072,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
Label Line None Position Center Font ("Arial",0,9,0) Pen (1,2,0)
With State_Name
Parallel On Auto Off Overlap Off Duplicates On Offset 2
Visibility On
Layer 3
Display Global
Global Pen (1,2,9474192) Brush (2,16768112,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
Label Line None Position Center Font ("Arial",0,9,0) Pen (1,2,0)
With Country
Parallel On Auto Off Overlap Off Duplicates On Offset 2
Visibility On
Layer 4
Display Graphic
Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
Label Line None Position Center Font ("Arial",0,9,0) Pen (1,2,0)
With Name
Parallel On Auto Off Overlap Off Duplicates On Offset 2
Visibility On
MapInfo Professional Menu Definition
MapInfo Menu File
PLEASE BE CAREFUL!!!!!!
Modifying the menu file
• Create Shell
• Write / “Steal” the Code
• Create Interface
• Run It
Create Shell
Sub Main
‘ code goes here
End Sub
Write/Steal The Code
• Do…Until/While…Loop
Do
…
Loop Until <condition>
• While <condition>
…
Wend
• Do While <condition>
…
Loop
Review