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.
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. 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:-
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
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:- 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:-
|
AuthorJoe 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
March 2024
Categories
All
|