English

How To: Communicate between two ArcView sessions through DDE

Summary

The following script demonstrates how to use: Request, Poke, and Execute, to communicate between two sessions of ArcView.

Procedure

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the code below into the new script window.

    Code:
    '-- Name current ArcView Server Session ArcDDE
    '
    DDEServer.StartNamed("ArcDDE")
    theDDE = DDEClient.Make("ArcView", "System")

    '-- Error Checking
    If (theDDE.Haserror) then
    av.usewaitcursor

    System.Execute("c:\esri\av_gis30\arcview\bin32\arcview.exe")
    n = 0
    While (n < 10000)
    n = n + 1
    end
    theDDE = DDEClient.Make("ArcView", "System")
    end

    '-- List of Available DDE functions
    theChoiceList = {"Send Request", "Send Data", "Request Data"}
    theChoice = Msgbox.ChoiceAsString(theChoiceList, "Enter a DDE function",
    "DDE")

    '-- If the user wants other App to do something
    If (theChoice = "Send Request") then
    theControl = msgbox.input("Enter the request for ArcView"
    ++NL++"Type ? to see sample requests","","")
    If (theControl = nil) then
    exit
    end
    If (theControl = "?") then
    theSamples = {"av.minimize", "av.maximize", "av.restore","View.Make"}
    theControl = MsgBox.Choiceasstring(theSamples, "Choose a sample request", "DDE Sample")
    end
    theDDE.Execute(theControl)
    end

    '-- If the user wants to pass info to other ArcView Session
    If (theChoice = "Send Data") then
    theItem = msgbox.input("Enter the item to pass to in other ArcView Application","","")
    If (theItem = nil) then
    exit
    end
    theData = msgbox.input("Enter data to pass", "DDE", "")
    If (theData = nil) then exit end
    theDDE.Poke(theItem, theData)
    end

    '-- If the user wants other App to give info
    If (theChoice = "Request Data") then
    theRequest = msgbox.input("Enter the request from ArcView "++NL++
    "Type ? to see sample requests","DDE Request","")
    If (theRequest = nil) then exit end
    If (theRequest = "?") then
    theSamples = {"av.getactivedoc.getname","av.getactivedoc.getcreationdate","date.now.asstring"}
    theRequest = MsgBox.Choiceasstring(theSamples, "Choose a sample request", "DDE Sample")
    end
    theDDErequest = theDDE.request(theRequest)
    Msgbox.Report(theDDErequest, "Here's the requested info")
    end

  3. Compile and run the script.