MapInfo Pro

Expand all | Collapse all

DDE conversation cannot initiate link

  • 1.  DDE conversation cannot initiate link

    Posted 29 days ago
    Edited by Mitchel Fielding 29 days ago
    I have two MBX applications communicating via DDE within the same MapInfo session.
    The application A triggers code to run in application B using DDEInitiate("MapInfo", "App_B.MBX") then DDEExecute.
    Application B is then attempting to retrieve the list of MapInfo applications using DDEInitiate("MapInfo", "System") and DDERequest$(nChan, "Topics")
    However, the DDERequest in App_B is then failing due to error 698 "Cannot initiate link".
    Note that App_A is using DDEInitiate("MapInfo", "System") and DDERequest$(nChan, "Topics") without problem elsewhere in the code.

    Any suggestions as to why the App_B call to DDERequest would fail this way?

    Using MapInfo 15 with code compiled to 12.5

    Thanks,
    Mitchel

    ------------------------------
    Mitchel Fielding
    Telstra
    ------------------------------


  • 2.  RE: DDE conversation cannot initiate link

    Posted 28 days ago
    For the sake of clarity, the simplified applications are:

    App_A.MB
    --------------
    Include "MapBasic.DEF"

    Declare Sub Main
    Declare Sub Do_Function

    Sub Main
    Create Menu "Application A" as
    "Do Function" Calling Do_Function

    Alter Menu Bar Add "Application A"
    End Sub

    Sub Do_Function
    Dim nChan As Integer

    CLS

    OnError Goto CatchEx
    nChan = DDEInitiate("MapInfo", "App_B.MBX")
    DDEExecute nChan, "DO_FUNCTION"
    DDETerminate nChan

    Exit Sub

    CatchEx:
    Note "ERROR: communicating with App B MapInfo application"
    Resume Done

    Done:
    Exit Sub

    End Sub


    App_B.MB
    --------------
    Include "MapBasic.DEF"

    Declare Sub Main
    Declare Sub RemoteMsgHandler

    Sub Main

    End Sub

    Sub RemoteMsgHandler
    Dim nChan As Integer
    Dim sTopics As String

    Do Case CommandInfo(CMD_INFO_MSG)
    Case "DO_FUNCTION"
    OnError Goto CatchEx
    nChan = DDEInitiate("MapInfo", "System")
    sTopics = DDERequest$(nChan, "Topics")
    DDETerminate nChan
    End Case

    Exit Sub

    CatchEx:
    Print "Error occurred in App B " & Err() & " " & Error$()
    Resume Done

    Done:
    Exit Sub

    End Sub


    ------------------------------
    Mitchel Fielding
    Telstra
    Sydney
    ------------------------------



  • 3.  RE: DDE conversation cannot initiate link

    Posted 28 days ago
    Hi Mitchel,

    It looks as though MapInfo can only handle one DDE conversation at a time.  I gave this a go in MapBasic 12.5, MapInfo 17 and the same thing happened.  If you execute the DDERequest$ in App_B before the DDE conversation is initiated by App_A (e.g. within the Main routine of App_B) it succeeds.  However this may not be what you want as it will not give you the most up to date list of "Topics".

    One suggestion I have is that you could use "Run Program" in App_A to start App_B, then within App_B start up the DDE conversation in reverse if you need to communicate with App_A.  That way App_B will have control over the DDE conversations it initiates.


    ------------------------------
    James Nolet
    Dooley Mitchell & Morrison Pty Ltd
    Mentone, VIC, Australia
    ------------------------------



  • 4.  RE: DDE conversation cannot initiate link

    Posted 28 days ago
    Thanks for your suggestions James - I think in this case the App B request could work in Main, and your second suggestion is a good backup otherwise.

    The reference manual states in the DDEInitiate() function that "a MapBasic program can carry on multiple conversations at the same time, limited
    only by memory and system resources."  Perhaps the limitation here is both conversations are happening within the same MapInfo session.

    Thanks again for your help - it should get me to the next issue :-)
    Mitchel

    ------------------------------
    Mitchel Fielding
    Telstra
    Sydney
    ------------------------------



  • 5.  RE: DDE conversation cannot initiate link

    Posted 28 days ago
    That's no problem - I'm glad I could help.

    ------------------------------
    James Nolet
    Dooley Mitchell & Morrison Pty Ltd
    Mentone, VIC, Australia
    ------------------------------