jps services
  • Home Page
  • GIS Training Courses
    • QGIS Training Courses
    • ArcGIS Training Courses
    • MapInfo Pro Training Courses >
      • MapBasic Training Course
  • About
  • Blog

MapBasic file formats: MB, MBX, MBO and MBP

17/12/2016

0 Comments

 
If you have look at a MapBasic text (*.MB) file you will see the code is in a format which could be created by many different types of text editor as well as MapBasic. However this type of text file needs to be compiled within the MapBasic program before it can be converted into an (*.MBX) which is an executable file. These executable (*.MBX) file types can then be run within the MapInfo Pro software to provide additional functionality.
Additionally, some MapBasic text files do not convert automatically to the (*.MBX) file format. This happens because they either do not have a Main() subroutine and/or the file contains routines which are declared but not defined within the file. In these circumstances the files will be compiled as (*.MBO) files. These compiled module files will not run within MapInfo Pro unless they are linked together within a project file. The project file format has the (*.MBP) file format.

So why does MapBasic have these different file formats? Some programs are fairly straight forward and can be completed with little code. In these circumstances everything can be included within the one program to make it run as an executable. Once programs become more complex then it makes sense to break up the tasks into a modular format and hence the development of the (*.MBO) format to facilitate this need.  
Another reason for having modular programs is so that code can be reused as required in different programs. The modular program also has the advantage of enabling modifications to be made to a specific part of the program without this impacting on the rest of the code. Error checking can be confined to only those modules with elements of code which have been upgraded or modified. All the other modules are therefore unaffected and only need to be linked together to create a new program once the specific module has been successfully compiled as an (*.MBO). By using modules rather than having one long complex program you can also make your subroutines and functions specific to certain tasks. This makes your code simpler to write and maintain.

Here is an example of the project file format:-

Picture
Note you can choose any name for your executable file although usually it relates to the program's application name. In the RibbonCustomizationMB.mbp the application name is the same as one of the (*.MBO) files: RibbonCustomizationMB.mbo. In the above example two files are linked to form the executable file.   
Picture

Read More
0 Comments

Standard and custom dialog boxes in MapBasic

12/12/2016

0 Comments

 
If you search for Dialog Statement in MapBasic Help you will see that its purpose is to create custom dialog boxes.
In  a previous blog we used the Note statement, which is the most basic of MapInfo’s standard dialogs. The Help section on Dialogs states: - “The Dialog statement lets you create a custom dialog box. If you want to display a standard dialog box (for example, a File>Open dialog box), use one of the following statements or functions: Ask() function, Note statement, ProgressBar statement, FileOpenDlg() function, FileSaveAsDlg() function, or GetSeamlessSheet() function).”

The Ask() function displays a dialog box which asks the user a yes or no question. The example in the Help section is as follows:-
​

Dim more As Logical
more = Ask("Do you want to continue?", "OK", "Stop")

This code by itself will not show an Ask dialogue box so please do not try and run this example. This is because it will cause MapInfo to run the program in the background without displaying the Ask dialogue box. The code will compile and can be run, but with the result of having to reboot your computer to cancel the code from the system. If curiosity gets the better of you and you run this code you will only be aware of the problem as the MapInfo icon at the bottom of your computer screen will flash intermittently. If you attempt to close MapInfo you will get a message saying that you cannot quit MapInfo. You can resolve the problem by restarting which will close MapInfo and the underlying problem. Needless to say you are better off just accepting that this code is to be run only as part of a larger section of code as shown in the code sample below:-


Read More
0 Comments

Using the OnError statement in MapBasic

6/12/2016

0 Comments

 
When you have successfully compiled your code you may still encounter problems when trying to run it in MapInfo Professional. This can stem from a number of reasons including logic errors, mistakes in how files are opened or closed, or syntax errors in an SQL statement for example.

MapBasic has a number of options to avoid code failing because of errors that can occur. One of these options is the OnError statement. Use the MapBasic Help to search for the OnError statement. Help describes this function as follows:  “The OnError statemement either enables an error-handling routine, or disables a previously enabled error-handler. (An error-handler is a group of statements executed in the event of an error).”
​
Below is an example of how the OnError statement could be used which is based on the code sample provided within MapBasic Help.​

Read More
0 Comments

    Author

    Joe Short BSc has been involved with various mapping solutions for over twenty years.  If you are considering implementing a GIS  or have ArcGIS Pro, MapInfo Pro or QGIS training requirements, jps services would be happy to be of assistance to your organisation. 

    Archives

    April 2020
    March 2020
    October 2019
    September 2019
    August 2019
    July 2019
    March 2019
    November 2018
    October 2018
    August 2018
    July 2018
    November 2017
    October 2017
    September 2017
    July 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    May 2016
    February 2016
    September 2015
    August 2015
    April 2015
    February 2015
    November 2014
    October 2014
    July 2014
    June 2014
    May 2014
    March 2014
    February 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    June 2013
    May 2013
    April 2013
    February 2013
    December 2012
    October 2012
    September 2012
    August 2012
    July 2012

    Categories

    All
    Arc Gis
    Arcview
    Autodesk
    Cad
    Gis Training
    Local Government
    Mapbasic
    Mapinfo
    Quantum Gis
    Relational Databases
    Saga Gis

    RSS Feed