Microsoft KB Archive/112047: Difference between revisions
(importing KB archive) |
m (Text replacement - "&" to "&") |
||
(One intermediate revision by the same user not shown) | |||
Line 33: | Line 33: | ||
<pre> of FoxPro for Windows that was just started: | <pre> of FoxPro for Windows that was just started: | ||
m.chan = ddeinitiate( | m.chan = ddeinitiate("DDEData","c:\foxprow\tutorial\;TABLE customer") | ||
NOTE: If necessary, | NOTE: If necessary, "c:\foxprow\tutorial\" should be changed to reflect | ||
the directory where the CUSTOMER.DBF file is located. Technically, | the directory where the CUSTOMER.DBF file is located. Technically, | ||
"DDEData" is the service name, and "c:\foxprow\tutorial\;TABLE customer" | |||
is the topic. | is the topic. | ||
Line 44: | Line 44: | ||
</pre> | </pre> | ||
6. To request some information from the server, type: | 6. To request some information from the server, type: | ||
<pre> m.names=dderequest(m.chan, | <pre> m.names=dderequest(m.chan,"FIELDNAMES") | ||
The variable m.names will contain a list of field names from the | The variable m.names will contain a list of field names from the | ||
CUSTOMER table separated by tabs. DDEDATA.APP is set up to recognize the | CUSTOMER table separated by tabs. DDEDATA.APP is set up to recognize the | ||
item | item "FIELDNAMES". | ||
Other items it can recognize include | Other items it can recognize include "ALL", "DATA", "NEXTROW", | ||
"PREVROW", "FIRSTROW", "LASTROW", and "FIELDCOUNT". | |||
</pre> | </pre> | ||
7. To get the next record's data, type: | 7. To get the next record's data, type: | ||
<pre> m.data=dderequest(m.chan, | <pre> m.data=dderequest(m.chan,"NEXTROW") | ||
The variable m.data will contain one record's fields separated by tabs. | The variable m.data will contain one record's fields separated by tabs. | ||
</pre> | </pre> | ||
8. To change the current record, type: | 8. To change the current record, type: | ||
<pre> m.confirm = ddepoke(m.chan, | <pre> m.confirm = ddepoke(m.chan,"Contact","Jane Doe") | ||
The variable m.confirm will contain a .T. if the action took place or a | The variable m.confirm will contain a .T. if the action took place or a | ||
.F. if it failed. In this case, DDEDATA.APP would replace the CONTACT | .F. if it failed. In this case, DDEDATA.APP would replace the CONTACT | ||
field with | field with "Jane Doe" on the current record. | ||
</pre> | </pre> | ||
9. To end the conversation, type: | 9. To end the conversation, type: | ||
Line 71: | Line 71: | ||
Additional features can be added to DDEDATA.APP. In order to do this, you must modify DDEDATA.PRG and then rebuild the application. This application simply institutes a large DO CASE statement in order to respond to different DDE messages. For example, even though DDEDATA.APP enables the DDEExecute service, it doesn't do anything with it. However, if you added | Additional features can be added to DDEDATA.APP. In order to do this, you must modify DDEDATA.PRG and then rebuild the application. This application simply institutes a large DO CASE statement in order to respond to different DDE messages. For example, even though DDEDATA.APP enables the DDEExecute service, it doesn't do anything with it. However, if you added | ||
<pre> Case sAction = | <pre> Case sAction = "EXECUTE" | ||
& | &sData | ||
</pre> | </pre> | ||
as part of the DO CASE statement in the cbDataTopic, then when you typed | as part of the DO CASE statement in the cbDataTopic, then when you typed | ||
<pre> m.confirm = ddeexecute(m.chan, | <pre> m.confirm = ddeexecute(m.chan,"wait window 'Hello'") | ||
</pre> | </pre> | ||
the instance of FoxPro running DDEDATA.APP would display a wait window with the text | the instance of FoxPro running DDEDATA.APP would display a wait window with the text "Hello". | ||
NOTE: The variable m.confirm again reveals if the command succeeded or failed. The & | NOTE: The variable m.confirm again reveals if the command succeeded or failed. The "&sData" line is simply using macro substitution. The contents of sData are interpreted by FoxPro as if they had been typed in the Command window. | ||
DDEDATA.APP can be modified to accept and respond to many more requests. It is simply a matter of changing the DO CASE statement to accommodate these new items. | DDEDATA.APP can be modified to accept and respond to many more requests. It is simply a matter of changing the DO CASE statement to accommodate these new items. | ||
Line 84: | Line 84: | ||
== REFERENCES == | == REFERENCES == | ||
"Developer's Guide," version 2.5, Chapter 12 | |||
"Language Reference," version 2.5, pages L3-371, L3-363, L3-366,L3-369, L3-382 | |||
Additional reference words: FoxWin 2.50 2.50a 2.50b DDEData KBCategory: kbinterop kbprg KBSubcategory: FxinteropDde | Additional reference words: FoxWin 2.50 2.50a 2.50b DDEData KBCategory: kbinterop kbprg KBSubcategory: FxinteropDde |
Latest revision as of 12:26, 21 July 2020
How to Perform DDE with DDEDATA.APPID: Q112047 2.50 2.50a 2.50b WINDOWS kbinterop kbprg The information in this article applies to:
SUMMARYFoxPro for Windows can be both a dynamic data exchange (DDE) server and a DDE client. FoxPro for Windows ships with DDEDATA.PJX and all the source code. Using this application, and two instances of FoxPro for Windows, one as the client and one as the server, it is easy to demonstrate the value of DDE, as shown below. MORE INFORMATIONNOTE: This article assumes that your machine has sufficient memory to run two instances of FoxPro for Windows. 1. Start FoxPro for Windows and open DDEDATA.PJX from the FOXPROW\SAMPLE\DDE subdirectory. 2. Build the application. 3. Run DDEDATA.APP. This application sets up this instance of FoxPro for Windows as a DDE Server. 4. Start another instance of FoxPro for Windows. 5. In order to establish the DDE link, type the following in the instance of FoxPro for Windows that was just started: m.chan = ddeinitiate("DDEData","c:\foxprow\tutorial\;TABLE customer") NOTE: If necessary, "c:\foxprow\tutorial\" should be changed to reflect the directory where the CUSTOMER.DBF file is located. Technically, "DDEData" is the service name, and "c:\foxprow\tutorial\;TABLE customer" is the topic. The variable m.chan will contain a value representing the DDE channel. All subsequent DDE commands will refer to this channel. 6. To request some information from the server, type: m.names=dderequest(m.chan,"FIELDNAMES") The variable m.names will contain a list of field names from the CUSTOMER table separated by tabs. DDEDATA.APP is set up to recognize the item "FIELDNAMES". Other items it can recognize include "ALL", "DATA", "NEXTROW", "PREVROW", "FIRSTROW", "LASTROW", and "FIELDCOUNT". 7. To get the next record's data, type: m.data=dderequest(m.chan,"NEXTROW") The variable m.data will contain one record's fields separated by tabs. 8. To change the current record, type: m.confirm = ddepoke(m.chan,"Contact","Jane Doe") The variable m.confirm will contain a .T. if the action took place or a .F. if it failed. In this case, DDEDATA.APP would replace the CONTACT field with "Jane Doe" on the current record. 9. To end the conversation, type: m.confirm = ddeterminate(m.chan) The variable m.confirm contains a .T. if the DDE link was terminated successfully. Additional features can be added to DDEDATA.APP. In order to do this, you must modify DDEDATA.PRG and then rebuild the application. This application simply institutes a large DO CASE statement in order to respond to different DDE messages. For example, even though DDEDATA.APP enables the DDEExecute service, it doesn't do anything with it. However, if you added Case sAction = "EXECUTE" &sData as part of the DO CASE statement in the cbDataTopic, then when you typed m.confirm = ddeexecute(m.chan,"wait window 'Hello'") the instance of FoxPro running DDEDATA.APP would display a wait window with the text "Hello". NOTE: The variable m.confirm again reveals if the command succeeded or failed. The "&sData" line is simply using macro substitution. The contents of sData are interpreted by FoxPro as if they had been typed in the Command window. DDEDATA.APP can be modified to accept and respond to many more requests. It is simply a matter of changing the DO CASE statement to accommodate these new items. REFERENCES"Developer's Guide," version 2.5, Chapter 12 "Language Reference," version 2.5, pages L3-371, L3-363, L3-366,L3-369, L3-382 Additional reference words: FoxWin 2.50 2.50a 2.50b DDEData KBCategory: kbinterop kbprg KBSubcategory: FxinteropDde Keywords : FxinteropDde Version : 2.50 2.50a 2.50b Platform : WINDOWS |
Last Reviewed: May 1, 1996 |