There's more to experience when you log in!
I was asked how to call a procedure in a running MapBasic application from another MapBasic application.
This can be done using the CallMBXSub method from the IMapInfoPro.def.
In IMapInfoPro.def you can find these two methods:
Declare Method MapBasicApplication Class "MapInfo.Types.IMapInfoPro" Lib "MapInfo.Types, Version=220.127.116.11, Culture=neutral, PublicKeyToken=1c8d81d2ee78b75d" alias GetMapBasicApplication (ByVal IMIProInstance As This, ByVal applicationName As String) As This
Declare Method CallMBXSub Class "MapInfo.Types.IMapBasicApplication" Lib "MapInfo.Types, Version=18.104.22.168, Culture=neutral, PublicKeyToken=1c8d81d2ee78b75d" alias CallMapBasicSubroutine (ByVal IMBXInstance As This, ByVal methodName As String, parameters() As String)
The first one can give you a reference to a running MapBasic application using the name of the application.
The second one lets you call a sub procedure in a running MapBasic application
Here's how you can use it:
Include "MapBasic.def"Include "IMapInfoPro.def"
Declare Sub Main
Dim theMapInfoApplication As ThisDim theOtherMapBasicApplication As ThisDim arrParams() As String 'Get the MapInfo Pro instance
theMapInfoApplication = SystemInfo(SYS_INFO_IMAPINFOAPPLICATION) 'Get the instance of the other MapBasic application theOtherMapBasicApplication = MapBasicApplication(theMapInfoApplication, "HexagonTool.mbx")
'Call the procedure in the other MapBasic application
Call CallMBXSub(theOtherMapBasicApplication, "MENUHexagons", arrParams)
In my example, my running application HexagonTool.mbx has a procedure called MENUHexagons that doesn't take any parameters. If your procedure does take parameters, you will have to add these to the array arrParam in the order the procedure requires them.