MapBasic 101

A 20 Minute Intro Lesson For Beginners
Presented at the Puget Sound MapInfo User Group
April 3, 1996
John Schlosser
Schlosser Geographic Systems, Inc.
206-224-0800


Three Problems Solved by MapBasic


Key Stages in Learning MapBasic

  1. Your first MapBasic “program” can simply be a MapBasic command (or commands) typed in the MapBasic window.
    Keep your “MapBasic Window” open all the time.
    This is called “using MapBasic without buying MapBasic.”
  2. Your second MapBasic “program” can be an edited Workspace file.
    Read your Workspace files.
    Use a word processing program or text editor to view or print.
    As long as you avoid variables you can do this without buying MapBasic.
  3. Modify and customize “template” code (filched from the MapBasic window or WOR file), to enhance extend your code.
    For a template, copy code that MapInfo automatically prints to the MapBasic window and/or cut and paste code from a Workspace file. For example, you can customize the code by adding variables, dialog boxes etc.
  4. Use MapBasic to make your own life easier, before programming code for others to run. Writing code for others to run is MUCH more complicated. It requires lots of code simply to trap for “mistakes” that darn user will make.


4 Strategies to Troubleshoot Code and Avoid Problems

  1. Document your code with lots of comments. In MapBasic, lines beginning with an apostrophe [ ` ]are comments.
  2. Create and follow standardized conventions about naming variables. Eg., All String variables have names that start with “s” (eg. sMyName); SmallInt variables have names that start with “m” (eg, mPop_1990).
  3. Test problem code fragments in the MapBasic window.
  4. Borrow code from sample MapBasic applications included with MapBasic. Search the sample code for occurrences of use of a specific MapBasic command that is troubling you.
  5. Get “structural.” Take a programming class (e.g., in MapBasic or Visual Basic). Learn how to make your code “modular” with an “efficient” structure.

All rights reserved, Schlosser Geographic Systems, Inc. Seattle, WA 206-224-0800. Permission is granted to reproduce this document for non commercial purposes, provided that the document is reproduced in its entirity, including this notice.