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

Updating menu based MapBasic code to the new ribbon based interface

11/1/2017

0 Comments

 
If you run any menu based MapBasic code in the latest version of MapInfo Pro it should still be available to use. The code is converted to accommodate the new ribbon interface. In this case your code will create a Legacy tab automatically as seen in the example below.
Picture
In many cases this is sufficient for the user and perhaps updating the code is not necessary. However, if the code does need to be updated then the process is not altogether a difficult task. All of the steps have been clearly explained by Peter Horsboll Moller in his slide presentations. Using the steps outlined in these presentations you could modify existing menu based code to a ribbon based solution.

To use the ribbon based interface used in the slide presentation examples, you also need some understanding of modular programming. Again this has been fully explained by Egg-Jan Polle in his pdf Modular Programming in MapBasic. As the example code for Modular Programming in MapBasic uses the menu based version of MapInfo Pro we could modify the User Interface Module: ProjectUI.mb. This module contains menu based code and can be used to demonstrate how to update existing code to a ribbon based interface. One of the advantages of modular code is that only those modules requiring changes need to be modified. All the other modules can be linked again to form the executable without further work or need for compiling of these modules.
Using the slide presentation we can create the appropriate file structures to create the revised version of this modular programming application. Below is the first stage in the process:-
Picture

Read More
0 Comments

MapBasic FileSaveAsDlg() Function

7/1/2017

0 Comments

 
Like the FileOpenDlg() function the FileSaveAsDlg() has four string arguments: the default path, default name, file type and a dialogue prompt. Just as the FileOpenDlg() function does not open files in the same way the FileSaveAsDlg() function does not save files. The FileSaveAsDlg() function returns a string representing a file path. The user can either choose a new name for the file or choose to overwrite an existing file.
Here is some sample code using the FileSaveAsDlg() function to save a file with a new name and then opening a map and browser for this new file

Read More
0 Comments

MapBasic FileOpenDlg() function

2/1/2017

0 Comments

 
The FileOpenDlg() function doesn’t actually open files, rather the function offers the user the option of opening a file. This function takes up to four string type arguments. These include a default path, a default name, a file type and a prompt in the header bar. If all four of these options are left as NULL, the default path is chosen, the default name is an empty string, file type is *.TAB and the default header prompt is “Open”.

​Below is a coding example showing how FileOpenDlg() can be used to prompt the user to select a file to open in MapInfo. The user in this case is not prompted to open a specific file. Note that even if a default path and name are offered the user is free to choose a different path and file name.
 'Program: File Open Dialog Program.mb
' Purpose: Demonstrate the FileOpenDlg() function
' Includes
Include "MAPBASIC.DEF"
' Declares
Declare Sub Main
Declare Sub WorkWithTable(ByVal sTargetTable As String)
' Function: Main()
' Purpose: Main Control
Sub Main()
' Create a variable to hold the chosen filename and assign the user's choice to this variable
Dim s_filename As String
s_filename = FileOpenDlg("","","","")
' Check to see if a filename has been chosen
      If (s_filename <> "") Then
         Open Table s_filename
         Call WorkWithTable(s_filename)
      Else
         Note "No table chosen. Closing the program."
         End Program
       End If
End Sub

' Procedure: WorkWithTable()
' Purpose: Carry out tasks on the table
Sub WorkWithTable(ByVal sTargetTable As String)
      If (sTargetTable <> "") Then
          ' Use TableInfo to obtain the tablename
          sTargetTable = TableInfo(0, TAB_INFO_NAME)
          Map From sTargetTable ‘Open a map
          Browse * From sTargetTable 'Open a browser
      Else
          Note "No Table Found"
          End Program
      End If
End Sub

If you run this code a dialogue box opens similar to the one below:-
Picture
Note that the default name for the dialogue box is Open, the file name is left blank and the file type defaults to TAB. The user can choose a file from this or another location. On this occasion STATES table is chosen as in the following screen:-
Picture

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

    September 2026
    April 2026
    October 2025
    May 2025
    March 2025
    March 2024
    October 2023
    September 2023
    August 2023
    March 2023
    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