Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DDE conversaton between 2 Apps written with VFP6. Possible?

Status
Not open for further replies.

Takusaan

Programmer
Sep 20, 2000
29
US
I have 2 different applications both created in VFP6. I tried to create a DDE conversation in between the two of them. I know that the link is established but the Request of data fails all the time. All the dde commands seem to fail except the ddeinitiate.
Here is the code for the dde client:

nchannel=ddeinitiate('Mirserv','system')
if nchannel<>-1

ddeexecute (nchannel,'select C_pat')
ddeexecute (nchannel,'scatter memvar')

mrecipid=DDEREQUEST(nchannel,'m.CRECIPID')
endif
nchannel returns a value (ncahnnel=0).
Can anyone help?
 
According to - BUG: Visual FoxPro May Ignore DDE Messages:
&quot;CAUSE - Dynamic data exchange (DDE) is an older method for inter-application communication, which has been supplanted by newer technologies.

RESOLUTION
If possible, use a different technology than DDE, such as COM.&quot;

Rick
 
Hi Takusaan

The DDEExecute may not work quite as you might expect.The command you send is normally the name of a procedure that will get called. However, in the VFP Help under DDESetTopic there is an example of what you want to do. Having said that, unless you have to support older programs, as Rick observes there's no reason to use DDE. Com/Ole automation is easier.

DDESetTopic( ) Function Example

The following example creates a basic sample server called myserver that supports Visual FoxPro command execution from a client application. The client application makes requests to myserver through the DO topic, and macro substitution is used to execute the client's command.

*** Set Visual FoxPro up as a DDE server ***
= DDESetService('myserver', 'DEFINE')
= DDESetService('myserver', 'EXECUTE', .T.)
= DDESetTopic('myserver', 'DO', 'DOTOPIC')
WAIT WINDOW 'Server portion service setup ... ' NOWAIT
*** Use Visual FoxPro as a DDE client ***
gnChannel = DDEInitiate('myserver','DO')
=DDEExecute(gnChannel, 'WAIT WINDOW &quot;Command Executed ... &quot;')
=DDETerminate(gnChannel)
PROCEDURE dotopic
PARAMETERS gnChannel, gcAction, gcItem, gData, gcFormat, gnAdvise
glResult = .F.
*** It's necessary to return .T. from an ***
*** INITIATE action or no connection is made ***
IF gcAction = 'INITIATE'
glResult = .T.
ENDIF
IF gcAction = 'EXECUTE'
&gData
glResult = .T.
ENDIF
IF gcAction = 'TERMINATE'
WAIT WINDOW 'Goodbye ... ' NOWAIT
glResult = .T.
ENDIF
RETURN glResult

After running this example program, you have set up Visual FoxPro service, which other applications can access. If you have Microsoft Excel, you can run the following Excel macro:

gnMyChan = INITIATE(&quot;myserver&quot;,&quot;DO&quot;)
=EXECUTE(MyChan,&quot;WAIT WINDOW 'Hi, this is EXCEL speaking'&quot;)
=RETURN( )

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top