TWIAV - Tips & tricks

TWIAV - Tips & tricks

MapBasic Code Samples

On this page you will find some MapBasic code samples, both the program source and the compiled application. Everything on this page is offered "as is" without warranty of any kind, either expressed or implied, including limitation warranties of merchantability, fitness for a particular purpose, and noninfringement.

Unless otherwise stated MapBasic 9.0 has been used to compile the files - this means that the MBXs offered here will only run with MapInfo Professional 9.0 or higher. If you want to use the tools with another (an older) version of MapInfo Professional, you will have to compile the tool using the relevant version of the Mapbasic compiler.

The MapBasic Code Samples Project

The goal of this project is to provide some examples of how to use certain MapBasic functionality - not to offer full-blown applications. The applications below each focus on one 'trick'. You can study the source, modify it to suit your needs and implement it in your own apps.

The following code samples are available here:

CreatePoint Sample Code

With this application you can import a txt file and create points in one step.

The input file should meet the following conditions:

  • it shoul be a Delimited ASCII file (*.txt)

  • the delimiter should be Tab

  • the first line in the file should contain column titles

  • there should be a column named Longitude (containing X coordinate information)

  • there should be a column named Latitude (containing Y coordinate information)

  • the projection/coordinate system of the coordinates should be:
    Longitude / Latitude (WGS 84) [EPSG: 4326]

If necessary, you can change the code to test it with your own files.

Sample Data

A file with sample data is included: Castles.txt. It contains a few castles in the French Loire Valley.

If you need a background map of France for the castles, you can have a look at the Geographic Data page.
castles in the French Loire Valley

Please see the file below for CreatePoint.MB and CreatePoint.MBX.

A sample file - Castles.txt - is also included in the zip file:

More code samples will follow...;-)

What do you think of these code samples? If you have any , please let me know.