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:

Layout Sample Code

This application provides an example of how to use the Layout statement in your MapBasic application.

After choosing one, more or all French regions and the paper size, you can click Print and the application will create a professional looking layout for each of the chosen regions (see sample output below).

Print Layout Sample Application

The scale and the orientation of the map are chosen automatically, based on the size and the form of the region.

Like with all the other samples on these pages - you will find the MapBasic (and C#) source code included, so you can use this sample to build your own batch mapping application. To start with you could replace the names of the table and columns mentioned in the Main procedure with your own table and column names. And you could add the logo of your own company or organization.

The PrintLayout.MBX included has been compiled with MapBasic 10.0.

Sample output from PrintLayout.MBX (view at original size to get a better picture) Please see the file below for PrintLayout.MB and PrintLayout.MBX and some other files and test data.

More code samples will follow...;-)

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