Microsoft KB Archive/108173

{| = Contents of FOXDATA.TXT in FOXPROW\GOODIES\FOXDATA =
 * width="100%"|

ID: Q108173

2.50 2.50a 2.50b WINDOWS kbreadme

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b

SUMMARY
Below is the complete FoxPro for Windows FOXDATA.TXT file found in the FOXPROW\GOODIES\FOXDATA subdirectory.

MORE INFORMATION
FoxData FoxData is a sample application that shows how FoxPro can be used as a dynamic data exchange (DDE) server. You can use FoxData to paste or link the contents of a FoxPro table or query to a Microsoft Excel spreadsheet, for example, or to create a tab-delimited Microsoft Word document. Full source code is included with the application. FoxData is located in the FOXPROW\GOODIES\FOXDATA directory.

A copy of this FoxData help information is also available in the FOXPROW\GOODIES\FOXDATA directory and is named FOXDATA.TXT. You may want to print FOXDATA.TXT to the printer for easier viewing.

FoxData DDE Server Dialog The FoxData DDE Server dialog contains these options:

Copy push button

Copies the selected table or query to the Clipboard, and puts sufficient DDE link information on the Clipboard to support the Paste or Paste Link options in the client application. Choosing Paste from a client application pastes a one-time snapshot of the copied FoxPro table or query into the client application's active document or spreadsheet. Choosing Paste Link creates a link between the client application and the FoxPro table or query so that the linked information will be   refreshed at least as often as every time you open the linked document or spreadsheet. Data may be updated even more frequently, depending upon the client application.

Use the popup to select the type of file (Table/DBF or Query) you want to copy. Select a file from the Copy Table or Query list, then choose Copy. Quit push button Exits FoxData without taking any action. Help push button Displays help information about FoxData. Include Field Names check box Check this check box to include the names of table or query fields in the data copied to the Clipboard. Directory push button Displays the Select Directory dialog so you can choose the drive and/or directory on which the desired table or query is located. Directory text display area Displays the currently selected directory. To change the directory, choose the Directory... push button. Number of DDE Clients area Displays the number of active DDE connections, and includes the following push button:

Show Log push button Enabled only when an error occurs in copying the table or     query to the Clipboard. Choose this button to view a log of the error(s). Using the FoxData Application To use the FoxData sample application, choose Do... from the FoxPro Program menu and select FOXDATA.APP from the FOXPROW\GOODIES\FOXDATA directory. The FoxData DDE Server dialog is displayed. Use this dialog to select a table or query and copy it to the Clipboard. Then access the client application and paste or link the copied data to the client application.

Copying from a FoxPro table to a Microsoft Excel spreadsheet

To copy, for example, the contents of the Sales table from FoxPro to a Microsoft Excel spreadsheet, select the Sales table from the FoxData DDE Server dialog and choose Copy. The contents of the Sales table are placed on the Clipboard. Click on cell A1 in a blank spreadsheet in Microsoft Excel, then choose Paste, Paste Special or Paste Link from the Edit menu in Excel. The contents of the Sales table are now pasted into the appropriate cells in the Excel spreadsheet. Copying from a FoxPro table to a Microsoft Word document To copy the contents of the table to Microsoft Word, you can choose Paste Special from the Word Edit menu and then choose Paste Link from the Paste Special dialog. The contents of the Sales table are formatted as tab-delimited rows in Microsoft Word. NOTE: It may take your computer a few moments to display the results of linking data between applications, especially if you're transferring large amounts of information. For example, if you choose Paste Link to paste FoxPro data into a spreadsheet, Excel first may fill the spreadsheet cells with the comment "#N/A" while the DDE transfer is taking place. In a moment or two the "#N/A" will clear from each cell and you will see the linked table fields and rows displayed in the appropriate cells. When you transfer data to a Microsoft Word document, Windows may display the hourglass for a moment or two, until the transfer is complete. Editing a Link To change the link between a FoxPro table or query and a client application, you can edit the link. The following illustrations refer to the links established in the "Using the FoxData Application" examples above.

Editing a link in a Microsoft Excel spreadsheet

To remove field names from the displayed FoxPro table or query information in a linked Excel spreadsheet, for example, select a non-blank cell and choose F2 to edit the cell's contents. Change the word "All" at the end of the command to "Data", then press CTRL+SHIFT+ENTER. The linked fields in the spreadsheet are redisplayed without field names. Editing a link in a Microsoft Word document To edit a link in a Microsoft Word document, choose Links... from the Edit menu in Word. Select the link you want to edit, then choose Change Link.... In the Change Link dialog, edit the information in the Item text box. For example, change the word "All" in the Item text box to "Data" and choose OK until you return to the document. The linked data is redisplayed without field names. For more information about manipulating linked data, refer to the manuals for the linked applications. DDE Commands and FoxData As a DDE server, FoxData responds to predetermined DDE commands. These commands are described in the following section. Normally you would build these commands into the application that is trying to access the data. The syntax used depends very much on the application that you're using. For example, Microsoft Excel has INITIATE, REQUEST and TERMINATE commands in its macro language. Microsoft Word uses DDEInitiate, DDERequest and DDETerminate from WordBasic. See your application's manual for how to use DDE with that application. (Note that sometimes you will need to find additional programming documentation to supplement the manuals that come with the product. Sometimes the information is in text files supplied on the application disks.)

Using FoxData as a DDE Server FoxData supports dynamic data exchange (DDE) as a source (server).

This section describes the five topics that FoxData supports as a DDE server and the items that are valid for each topic. The five topics are, , "SQL ", and "System".

Topic

When requesting the contents of a table, you may specify the directory the object is in, followed by a semicolon, the key word TABLE, and then the name of an existing table.

The syntax for this topic is:

[ ;]TABLE

For example, to request the contents of the Sales table in the FoxPro FOXDATA subdirectory, you can type just the name of the table or its full path:

TABLE Sales

-or-

c:\FOXPROW\GOODIES\FOXDATA;TABLE Sales

NOTE: Do not enclose table name in brackets ([]).

The following table lists the items that are valid with the topic.

Item        Returns -

All         All the data in the table, including field names. Data        All rows of data without field names. NextRow     The next row in the table or query. When you first initiate a channel, NextRow returns the first row. If              the current row is the last record and you execute NextRow, the request fails. PrevRow     The previous row in the table or query. If PrevRow is              the first request over a new channel, the last row of               the table or query is returned. If the current row is              the first record, the request for PrevRow fails. FirstRow    The data in the first row of the table or query. LastRow     The data in the last row of the table or query. The value of field for the current row. FieldCount  The number of the fields in the table or query. FieldNames  A list of field names.

The topic also supports a DDE poke command from another application. You can change the contents of a field by supplying a field name and the new data value. Topic The topic supports the same items as the topic. To copy a query using FoxData the query output must be directed to a table or cursor. When requesting the results of a query, you may specify the directory the object is in, followed by a semicolon, the key word QUERY, and then the name of an existing query.

The syntax for this topic is:

[ ;]QUERY

For example, to request the results of the Westsale query in the FoxPro FOXDATA subdirectory, you can type just the name of the query or its full path:

QUERY Westsale

-or-

c:\FOXPROW\GOODIES\FOXDATA;QUERY Westsale

NOTE: Do not enclose query names in brackets ([]).

For a list of items that are valid with the topic, refer to the table of items in the topic above. "SQL " The "SQL " topic returns the results of the specified SQL expression. The syntax for this topic is:

[ ;]SQL 

For example, to select all fields from the Sales table in the FoxPro FOXDATA directory, enter:

c:\FOXPROW\GOODIES\FOXDATA;SQL Select * from Sales;

To select only the values in the Fourthqtr field in the Sales table, enter:

c:\FOXPROW\GOODIES\FOXDATA;SQL Select Fourthqtr from Sales;

NOTE: End each SQL statement with a semicolon.

The "SQL " topic supports the same items as the and topics. Topic is the directory that contains tables, queries, screens and other directory elements. This topic can be a fully qualified path. After you initiate a DDE link with a directory, you can request a listing of the objects in that directory. Initiating this Topic has the effect of setting the default directory to the one specified.

Item         Returns

TableList    A list of .DBF files in the path QueryList    A list of .QPR files in the path MacroList    A list of .FKY files in the path ReportList   A list of .FRX files in the path ScreenList   A list of .SPR files in the path FormList     Synonym for ScreenList ModuleList   A list of .APP and .PRG files in the path "System" Topic "System" is a standard topic for all Windows applications. It returns information about the topics FoxData supports. The following table lists the valid items for the "System" topic.

Item        Returns -

SysItems    A list of items supported by the topic "System" Format      A list of the formats FoxData can copy onto the Clipboard Status      "Busy" or "Ready" Executes a FoxPro command

Note: To send a command to FoxData, use the DDEExecute statement. Some commands may interfere with the internal operation of FoxData. If you wish to send extensive command sequences to FoxPro it is probably better to write a server to specifically match your needs. Installing FoxData as a    Program Manager Icon To install FoxData as an application in the Microsoft Windows Program Manager, click on your FoxPro program group window to make it active, then choose New... from the File menu in Program Manager. In the New Program Object dialog, choose the New Program Item radio button, then choose OK. Enter the following information in the Program Item Properties dialog:

Text Box Name       Enter ---

Description         FoxData Command Line        c:\foxprow\foxprow.exe foxdata.app Working Directory   c:\foxprow\goodies\foxdata Choose the Change Icon... push button. In the Change Icon dialog, choose the Browse... push button. In the Browse dialog, choose the C:\FOXPROW\GOODIES\FOXDATA directory, be sure that Icon Files is selected in the List Files of Type popup, and then select FOXDATA.ICO as the icon file. Choose OK until you return to the Program Item Properties dialog, then choose OK to return to the FoxPro program group window in the Program Manager and view the newly installed FoxData icon. Now when you double- click on the FoxData icon, FoxPro launches the FoxData application and displays the FoxData DDE Server dialog. More About FoxPro and DDE For more information about using DDE with FoxPro, refer to the "Dynamic Data Exchange (DDE)" chapter in the FoxPro "Developer's Guide."

Note that the commands outlined above are modeled on Microsoft Access's DDE Server functionality and are designed to be compatible. If you are careful to follow these command standards when you write programs that use FoxData, you'll be able to use either FoxPro or Microsoft Access to store your data.

Additional reference words: FoxWin 2.50 2.50a 2.50b KBCategory: kbreadme KBSubcategory: FxinteropDde

Keywords         : FxinteropDde Version          : 2.50 2.50a 2.50b Platform         : WINDOWS
 * }