The information in this article applies to:
SUMMARYWhen a dynamic data exchange (DDE) client application starts FoxPro for Windows and runs a program that sets up FoxPro as a DDE server application, the client application may need to pause while FoxPro's server program is loading. Not waiting until FoxPro is properly configured can result in error messages stating that the DDE server is unobtainable.
MORE INFORMATIONThe following Microsoft Excel macro requires a pause. ("A1" indicates cell A1 on a Microsoft Excel macro sheet.). A1: =EXEC("foxprow.exe c:\foxprow\tutorial\ddeserve.prg",3) A2: =APP.ACTIVATE() A3: m.initial.chan=INITIATE("myserver","DO") A4: =EXECUTE(m.initial.chan,"SET DEFAULT TO c:\foxprow\tutorial") A5: =EXECUTE(m.initial.chan,"USE customer") A6: =TERMINATE(m.initial.chan) A7: =RETURN() This Microsoft Excel macro launches FoxPro and runs the DDESERVE.PRG program (found below), which sets up FoxPro as a server application to accept commands from a DDE client application (Microsoft Excel in this case). A1: =EXEC("foxprow.exe c:\foxprow\tutorial\ddeserve.prg",3) A2: =APP.ACTIVATE() A3: =WAIT(NOW()+"00:00:03") A4: m.initial.chan=INITIATE("myserver","DO") A5: =EXECUTE(m.initial.chan,"SET DEFAULT TO c:\foxprow\tutorial") A6: =EXECUTE(m.initial.chan,"USE customer") A7: =TERMINATE(m.initial.chan) A8: =RETURN() The above WAIT() statement in cell A3 tells Microsoft Excel to pause the macro 3 seconds, giving FoxPro a chance to finish loading its server program before Microsoft Excel tries to open a channel to it. The DDESERVE.PRG Program*** Save as DDESERVE.PRG in the \FOXPROW\TUTORIAL directory *** *** Set FoxPro up as a DDE server *** = DDESetService('myserver', 'DEFINE') = DDESetService('myserver', 'EXECUTE', .T.) = DDESetTopic('myserver', 'DO', 'DOTOPIC') PROCEDURE dotopic PARAMETERS channel, action, item, data, format, advise mresult = .F. *** It's necessary to return .T. from an *** *** INITIATE action or no connection is made *** IF action = 'INITIATE' mresult = .T. ENDIF IF action = 'EXECUTE' &data mresult = .T. ENDIF IF action = 'TERMINATE' WAIT WINDOW 'Goodbye ... ' NOWAIT mresult = .T. ENDIF RETURN mresult
REFERENCESMicrosoft Excel "Function Reference" Additional query words: FoxWin 2.50 SetServer SetTopic Keywords : FxinteropDde Version : 2.50 2.50a Platform : WINDOWS Issue type : |
Last Reviewed: August 25, 1999 |