This post tries to outline some tips on how to get started with MapBasic, the scripting language for MapInfo Pro.
I have listed some of the good suggestions that came to a similar question on GIS StackExchange years ago.
I shared this tip:
Also if you are looking for a way to learn MapBasic more than a way to learn to program, there is a huge help in MapInfo Pro thru the MapBasic window.
Open the MapBasic window (Options > Show MapBasic Window) and do the task you want to code in MapBasic in MapInfo Pro. MapInfo Pro will now write the MapBasic statements required. You can now copy these into your MapBasic source code and work from this.
It's not all that can be done this way, but it gives you a very good insight into a lot of the MapBasic statements
Sancarn shared his thoughts on how he learned MapBasic:
Sorry for digging out an old thread, but the MapBasic UserGuide and MapBasic Reference are probably the 2 best resources for getting started with MapBasic.
I myself started off simply observing code generation in the MapBasic Window (see what Peter suggested). Then I started making my own MapBasic Window scripts in Excel:
Then after a while, I found out that MapBasic can be compiled into .MBX tools and these have the benefit of being able to use Loops, Flow control, dialogues etc.
So then I started writing .mb files and compiling them to .MBX. After a little while longer I started wanting to make MapBasic applications with Ribbon Buttons. You can do this with the Alter ButtonPad statement but it is better to use the RIBBONLib created by Peter. To do so you need to get started with .MBPs - I found this difficult but got there in the end.
As you can see from my own experience, I've learned more as and when I wanted it and have always strove to develop my knowledge. This has involved lots of googling, lots of reading in the MapBasic reference/user guide, lots of talking to PBSupport, and lots of reading from (and asking questions on) the MapInfo-L google group.
Writing MapBasic code
As for actual writing MapBasic application, I will only recommend the MapBasic Text Editor for small projects. As soon as you start creating more advanced projects I would recommend that you find a better text editor.
One option here would be to use the MapBasic IDE developed by Mustafa ÖZÇETİN. On the blog, you can find a very good guide to getting started with the MapBasic IDE.
I will add that it's been a while since there has been an upgrade to the MapBasic IDE.
Mr Chimp wrote:
I would highly recommend setting up Notepad++ (or something similar). Syntax highlighting, bulk indenting, and bulk commenting can speed things up massively.
Notepad++ certainly has grown in popularity, and it's free. There are a few useful resources for setting up Notepad++ to be used for writing MapBasic code. There is a good explanation on TWIAV and even here on the Knowledge Communities you can find a post with the keywords for MapBasic v2021.1.
There is also the option of using an actual IDE, like Microsoft Visual Code. This has been discussed earlier here in the community.
Personally, I have used UltraEdit and/or UEStudio. Probably mostly due to decades of habit. It does come with many great text editing features and allows you to call the MapBasic compiler to get your source code compiled.
Generally, I would certainly recommend using a "real" text editor, or IDE instead of the simple MapBasic editor.
There were also a number of additional resources shared in these threads:
Introduction to MapBasic
I have just started a series of articles on MapBasic. The idea is to take the readers from the very basics and help them build and structure a modular MapBasic application. I have around 10 articles planned for now on this topic.
I will keep the list of articles updated here:
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data